Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
Brakeman
提交
b31bc384
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 搜索 >>
提交
b31bc384
编写于
6月 07, 2013
作者:
J
Justin Collins
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add tests for branch limiting
上级
6bbe03cd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
90 addition
and
0 deletion
+90
-0
test/tests/alias_processor.rb
test/tests/alias_processor.rb
+79
-0
test/tests/sexp.rb
test/tests/sexp.rb
+11
-0
未找到文件。
test/tests/alias_processor.rb
浏览文件 @
b31bc384
...
...
@@ -262,6 +262,85 @@ class AliasProcessorTests < Test::Unit::TestCase
RUBY
end
def
test_default_branch_limit_5
assert_alias
"(6 or 7) or 8"
,
<<-
RUBY
x = 0
if something
x = 1
else
x = 2
end
x = 3 unless this
x = 4 if that
if another_thing
x = 5
else
x = 6
end
x = 7 if getting_crazy
x = 8 if so_crazy
x
RUBY
end
def
test_default_branch_limit_not_reached
assert_alias
"(((1 or 2) or 3) or 4)"
,
<<-
RUBY
x = 1
if something
x = 2
else
x = 3
end
x = 4 unless this
x
RUBY
end
def
test_default_branch_limit_before_reset_with_option
expected_y
=
RubyParser
.
new
.
parse
"((((0 or 1) or 2) or 3) or 4)"
expected_x
=
RubyParser
.
new
.
parse
"5 or 6"
original_sexp
=
RubyParser
.
new
.
parse
<<-
RUBY
x = 0
if something
x = 1
else
x = 2
end
if another_thing
x = 3
else
x = 4
end
y = x
x = 5 if getting_crazy
x = 6 if so_crazy
[x, y]
RUBY
tracker
=
Struct
.
new
(
"FakeTracker"
,
:options
).
new
(
:branch_limit
=>
4
)
assert_equal
4
,
tracker
.
options
[
:branch_limit
]
processed_sexp
=
Brakeman
::
AliasProcessor
.
new
(
tracker
).
process_safely
original_sexp
result
=
processed_sexp
.
last
assert_equal
expected_x
,
result
[
1
]
assert_equal
expected_y
,
result
[
2
]
end
def
test_simple_block_args
assert_alias
'1'
,
<<-
RUBY
y = 1
...
...
test/tests/sexp.rb
浏览文件 @
b31bc384
...
...
@@ -352,4 +352,15 @@ class SexpTests < Test::Unit::TestCase
s
.
original_line
=
100
assert_equal
100
,
s
.
original_line
end
def
test_combine_and_or_depth
e
=
Sexp
.
new
(
:lit
,
0
)
3
.
times
do
|
i
|
e
=
e
.
combine
(
Sexp
.
new
(
:lit
,
i
))
end
assert_equal
s
(
:or
,
s
(
:or
,
s
(
:or
,
s
(
:lit
,
0
),
s
(
:lit
,
0
)),
s
(
:lit
,
1
)),
s
(
:lit
,
2
)),
e
assert_equal
3
,
e
.
or_depth
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录