Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
Brakeman
提交
a661118a
B
Brakeman
项目概览
李少辉-开发者
/
Brakeman
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
Brakeman
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a661118a
编写于
9月 18, 2012
作者:
J
Justin Collins
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add tests for OutputProcessor
上级
6b3991dd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
146 addition
and
0 deletion
+146
-0
test/tests/test_output_processor.rb
test/tests/test_output_processor.rb
+146
-0
未找到文件。
test/tests/test_output_processor.rb
0 → 100644
浏览文件 @
a661118a
class
OutputProcessorTests
<
Test
::
Unit
::
TestCase
def
assert_output
expected
,
original
output
=
Brakeman
::
OutputProcessor
.
new
.
format
original
assert_equal
expected
,
output
end
def
test_output_nil
assert_output
""
,
nil
end
def
test_output_empty_sexp
assert_output
""
,
Sexp
.
new
end
def
test_output_missing_node_type
assert_output
""
,
Sexp
.
new
(
Sexp
.
new
(
:str
,
'x'
))
end
def
test_output_bad_input
assert_output
""
,
Sexp
.
new
(
:call
,
"what is this doing here"
,
Sexp
.
new
(
:huh
))
end
def
test_output_local_variable
assert_output
"(local x)"
,
Sexp
.
new
(
:lvar
,
:x
)
end
def
test_output_ignore
assert_output
"[ignored]"
,
Sexp
.
new
(
:ignore
,
:whatever
)
end
def
test_output_params
assert_output
"params"
,
Sexp
.
new
(
:params
,
:anything
)
end
def
test_output_session
assert_output
"session"
,
Sexp
.
new
(
:session
)
end
def
test_output_cookies
assert_output
"cookies[:yum]"
,
Sexp
.
new
(
:call
,
Sexp
.
new
(
:cookies
),
:[]
,
Sexp
.
new
(
:arglist
,
Sexp
.
new
(
:lit
,
:yum
)))
end
def
test_output_output
assert_output
"[Output] (local x)"
,
Sexp
.
new
(
:output
,
Sexp
.
new
(
:lvar
,
:x
))
end
def
test_output_output_format
assert_output
""
,
Sexp
.
new
(
:output
,
Sexp
.
new
(
:format
,
Sexp
.
new
(
:str
,
'bye'
)))
end
def
test_output_escaped_output
assert_output
'[Escaped Output] @x'
,
Sexp
.
new
(
:escaped_output
,
Sexp
.
new
(
:ivar
,
:@x
))
end
def
test_output_string_output
assert_output
''
,
Sexp
.
new
(
:output
,
Sexp
.
new
(
:str
,
'x'
))
assert_output
''
,
Sexp
.
new
(
:escaped_output
,
Sexp
.
new
(
:str
,
'x'
))
end
def
test_output_format_string_literal
assert_output
""
,
Sexp
.
new
(
:output
,
Sexp
.
new
(
:format
,
Sexp
.
new
(
:str
,
'hi'
)))
end
def
test_output_escaped_format_string_literal
assert_output
""
,
Sexp
.
new
(
:escaped_output
,
Sexp
.
new
(
:format
,
Sexp
.
new
(
:str
,
'hi'
)))
end
def
test_output_string_interp
assert_output
'"#{@x}"'
,
Sexp
.
new
(
:string_interp
,
""
,
Sexp
.
new
(
:string_eval
,
Sexp
.
new
(
:ivar
,
:@x
)))
end
def
test_output_format
assert_output
"[Format] @x"
,
Sexp
.
new
(
:format
,
Sexp
.
new
(
:ivar
,
:@x
))
end
def
test_output_format_escaped
assert_output
"[Escaped] @x"
,
Sexp
.
new
(
:format_escaped
,
Sexp
.
new
(
:ivar
,
:@x
))
end
def
test_output_format_escaped_string_literal
assert_output
""
,
Sexp
.
new
(
:format_escaped
,
Sexp
.
new
(
:str
,
"hi"
))
end
def
test_output_format_escaped_with_escaped_literal
assert_output
""
,
Sexp
.
new
(
:format_escaped
,
Sexp
.
new
(
:escaped_output
,
Sexp
.
new
(
:str
,
'hi'
)))
end
def
test_output_format_string_literal
assert_output
""
,
Sexp
.
new
(
:format
,
Sexp
.
new
(
:str
,
"hi"
))
end
def
test_output_format_escaped_literal
assert_output
""
,
Sexp
.
new
(
:format
,
Sexp
.
new
(
:escaped_output
,
Sexp
.
new
(
:str
,
'hi'
)))
end
def
test_output_unknown_model
assert_output
"(Unresolved Model)"
,
Sexp
.
new
(
:const
,
Brakeman
::
Tracker
::
UNKNOWN_MODEL
)
end
def
test_output_render
assert_output
'render(partial => "x/y", { :locals => ({ :user => (@user) }) })'
,
Sexp
.
new
(
:render
,
:partial
,
Sexp
.
new
(
:str
,
"x/y"
),
Sexp
.
new
(
:hash
,
Sexp
.
new
(
:lit
,
:locals
),
Sexp
.
new
(
:hash
,
Sexp
.
new
(
:lit
,
:user
),
Sexp
.
new
(
:ivar
,
:@user
))))
end
def
test_output_rlist
assert_output
"a
\n
b"
,
Sexp
.
new
(
:rlist
,
Sexp
.
new
(
:call
,
nil
,
:a
,
Sexp
.
new
(
:arglist
)),
Sexp
.
new
(
:call
,
nil
,
:b
,
Sexp
.
new
(
:arglist
)))
end
def
test_output_call_with_block
assert_output
"x do
\n
y
\n
end"
,
Sexp
.
new
(
:call_with_block
,
Sexp
.
new
(
:call
,
nil
,
:x
,
Sexp
.
new
(
:arglist
)),
Sexp
.
new
(
:call
,
nil
,
:y
,
Sexp
.
new
(
:arglist
)))
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录