Skip to content

Commit 4ff85d5

Browse files
committed
Ruby: add test case
1 parent d5478a0 commit 4ff85d5

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

ruby/ql/test/library-tests/controlflow/graph/Cfg.expected

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3649,7 +3649,7 @@ cfg.rb:
36493649
#-----| -> call to foo
36503650

36513651
# 205| ...
3652-
#-----| -> exit cfg.rb (normal)
3652+
#-----| -> filter_nil
36533653

36543654
# 205| call to bar
36553655
#-----| -> if ...
@@ -3687,6 +3687,49 @@ cfg.rb:
36873687
# 205| x
36883688
#-----| -> exit { ... } (normal)
36893689

3690+
# 207| enter filter_nil
3691+
#-----| -> list
3692+
3693+
# 207| exit filter_nil
3694+
3695+
# 207| exit filter_nil (normal)
3696+
#-----| -> exit filter_nil
3697+
3698+
# 207| filter_nil
3699+
#-----| -> exit cfg.rb (normal)
3700+
3701+
# 207| list
3702+
#-----| -> list
3703+
3704+
# 208| list
3705+
#-----| -> do ... end
3706+
3707+
# 208| call to reject
3708+
#-----| -> exit filter_nil (normal)
3709+
3710+
# 208| do ... end
3711+
#-----| -> call to reject
3712+
3713+
# 208| enter do ... end
3714+
#-----| -> elem
3715+
3716+
# 208| exit do ... end
3717+
3718+
# 208| exit do ... end (normal)
3719+
#-----| -> exit do ... end
3720+
3721+
# 208| elem
3722+
#-----| -> rest
3723+
3724+
# 208| rest
3725+
#-----| -> elem
3726+
3727+
# 209| elem
3728+
#-----| -> call to nil?
3729+
3730+
# 209| call to nil?
3731+
#-----| -> exit do ... end (normal)
3732+
36903733
desugar.rb:
36913734
# 1| enter m1
36923735
#-----| -> x

ruby/ql/test/library-tests/controlflow/graph/Nodes.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ callsWithNoArguments
4242
| cfg.rb:200:1:200:32 | call to times |
4343
| cfg.rb:202:1:202:35 | call to times |
4444
| cfg.rb:205:1:205:3 | call to foo |
45+
| cfg.rb:208:3:210:5 | call to reject |
46+
| cfg.rb:209:5:209:13 | call to nil? |
4547
| desugar.rb:6:3:6:7 | call to foo |
4648
| desugar.rb:10:3:10:7 | call to foo |
4749
| desugar.rb:14:3:14:7 | call to foo |

ruby/ql/test/library-tests/controlflow/graph/cfg.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ def forward_param(a, b, ...)
204204
# A call with a safe navigation operator
205205
foo&.bar(1,2) { |x| x }
206206

207+
def filter_nil list
208+
list.reject do |elem, *rest|
209+
elem.nil?
210+
end
211+
end
212+
207213
__END__
208214

209215
Some ignored nonsense

0 commit comments

Comments
 (0)