Skip to content

Commit a7b3f13

Browse files
committed
Ruby: CFG: add test case
1 parent d0aa307 commit a7b3f13

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

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

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ case.rb:
10101010
#-----| -> value
10111011

10121012
# 69| case_match_various
1013-
#-----| -> exit case.rb (normal)
1013+
#-----| -> case_match_guard_no_else
10141014

10151015
# 69| exit case_match_various
10161016

@@ -1311,6 +1311,51 @@ case.rb:
13111311
#-----| raise -> exit case_match_various (abnormal)
13121312
#-----| match -> exit case_match_various (normal)
13131313

1314+
# 95| enter case_match_guard_no_else
1315+
#-----| -> value
1316+
1317+
# 95| case_match_guard_no_else
1318+
#-----| -> exit case.rb (normal)
1319+
1320+
# 95| exit case_match_guard_no_else
1321+
1322+
# 95| exit case_match_guard_no_else (abnormal)
1323+
#-----| -> exit case_match_guard_no_else
1324+
1325+
# 95| exit case_match_guard_no_else (normal)
1326+
#-----| -> exit case_match_guard_no_else
1327+
1328+
# 95| value
1329+
#-----| -> case ...
1330+
1331+
# 96| case ...
1332+
#-----| -> value
1333+
1334+
# 96| value
1335+
#-----| -> in ... then ...
1336+
1337+
# 97| in ... then ...
1338+
#-----| -> x
1339+
1340+
# 97| x
1341+
#-----| match -> x
1342+
1343+
# 97| ... == ...
1344+
#-----| true -> 6
1345+
#-----| raise -> exit case_match_guard_no_else (abnormal)
1346+
1347+
# 97| x
1348+
#-----| -> 5
1349+
1350+
# 97| 5
1351+
#-----| -> ... == ...
1352+
1353+
# 97| then ...
1354+
#-----| -> exit case_match_guard_no_else (normal)
1355+
1356+
# 97| 6
1357+
#-----| -> then ...
1358+
13141359
cfg.html.erb:
13151360
# 5| enter cfg.html.erb
13161361
#-----| -> @title

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ positionalArguments
9090
| case.rb:77:8:77:18 | call to [] | case.rb:77:11:77:13 | :"foo" |
9191
| case.rb:77:8:77:18 | call to [] | case.rb:77:15:77:17 | :"bar" |
9292
| case.rb:85:15:85:21 | ... == ... | case.rb:85:20:85:21 | 10 |
93+
| case.rb:97:13:97:18 | ... == ... | case.rb:97:18:97:18 | 5 |
9394
| cfg.html.erb:6:9:6:58 | call to stylesheet_link_tag | cfg.html.erb:6:29:6:41 | "application" |
9495
| cfg.html.erb:6:9:6:58 | call to stylesheet_link_tag | cfg.html.erb:6:44:6:58 | Pair |
9596
| cfg.html.erb:12:11:12:33 | call to link_to | cfg.html.erb:12:19:12:21 | "A" |

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,9 @@ def case_match_various value
9191
in (0 | "" | [] | {})
9292
end
9393
end
94+
95+
def case_match_guard_no_else value
96+
case value
97+
in x if x == 5 then 6
98+
end
99+
end

0 commit comments

Comments
 (0)