8000 Add test case · github/codeql@20022b6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 20022b6

Browse files
committed
Add test case
1 parent aad42b1 commit 20022b6

File tree

9 files changed

+85
-1
lines changed

9 files changed

+85
-1
lines changed

ruby/ql/test/library-tests/ast/Ast.expected

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,19 @@ control/cases.rb:
12751275
# 162| getKey: [SymbolLiteral] :y
12761276
# 162| getComponent: [StringTextComponent] y
12771277
# 162| getValue: [IntegerLiteral] 1
1278+
# 164| getStmt: [CaseExpr] case ...
1279+
# 165| getValue: [LocalVariableAccess] foo
1280+
# 166| getBranch: [WhenClause] when ...
1281+
# 166| getPattern: [IntegerLiteral] 1
1282+
# 166| getBody: [StmtSequence] then ...
1283+
# 166| getStmt: [IntegerLiteral] 2
1284+
# 169| getStmt: [CaseExpr] case ...
1285+
# 170| getValue: [LocalVariableAccess] foo
1286+
# 171| getBranch: [InClause] in ... then ...
1287+
# 171| getPattern: [IntegerLiteral] 3
1288+
# 171| getBody: [StmtSequence] then ...
1289+
# 171| getStmt: [StringLiteral] "three"
1290+
# 171| getComponent: [StringTextComponent] three
12781291
modules/classes.rb:
12791292
# 2| [Toplevel] classes.rb
12801293
# 3| getStmt: [ClassDeclaration] Foo
@@ -2888,6 +2901,9 @@ operations/operations.rb:
28882901
# 104| getElement: [IntegerLiteral] 1
28892902
# 104| getElement: [IntegerLiteral] 2
28902903
# 104| getElement: [IntegerLiteral] 3
2904+
# 106| getStmt: [DivExpr] ... / ...
2905+
# 106| getAnOperand/getLeftOperand/getReceiver: [LocalVariableAccess] foo
2906+
# 107| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 5
28912907
params/params.rb:
28922908
# 1| [Toplevel] params.rb
28932909
# 4| getStmt: [Method] identifier_method_params

ruby/ql/test/library-tests/ast/TreeSitter.expected

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2756,6 +2756,30 @@ control/cases.rb:
27562756
# 162| 1: [ReservedWord] :
27572757
# 162| 2: [Integer] 1
27582758
# 162| 4: [ReservedWord] }
2759+
# 164| 19: [Case] Case
2760+
# 164| 0: [ReservedWord] case
2761+
# 165| 1: [Identifier] foo
2762+
# 166| 2: [When] When
2763+
# 166| 0: [ReservedWord] when
2764+
# 166| 1: [Pattern] Pattern
2765+
# 166| 0: [Integer] 1
2766+
# 166| 2: [Then] Then
2767+
# 166| 0: [ReservedWord] then
2768+
# 166| 1: [Integer] 2
2769+
# 167| 3: [ReservedWord] end
2770+
# 169| 20: [CaseMatch] CaseMatch
2771+
# 169| 0: [ReservedWord] case
2772+
# 170| 1: [Identifier] foo
2773+
# 171| 2: [InClause] InClause
2774+
# 171| 0: [ReservedWord] in
2775+
# 171| 1: [Integer] 3
2776+
# 171| 2: [Then] Then
2777+
# 171| 0: [ReservedWord] then
2778+
# 171| 1: [String] String
2779+
# 171| 0: [ReservedWord] "
2780+
# 171| 1: [StringContent] three
2781+
# 171| 2: [ReservedWord] "
2782+
# 172| 3: [ReservedWord] end
27592783
# 1| [Comment] # Define some variables used below
27602784
# 7| [Comment] # A case expr with a value and an else branch
27612785
# 17| [Comment] # A case expr without a value or else branch
@@ -5636,6 +5660,10 @@ operations/operations.rb:
56365660
# 104| 4: [ReservedWord] ,
56375661
# 104| 5: [Integer] 3
56385662
# 104| 6: [ReservedWord] ]
5663+
# 106| 73: [Binary] Binary
5664+
# 106| 0: [Identifier] foo
5665+
# 106| 1: [ReservedWord] /
5666+
# 107| 2: [Integer] 5
56395667
# 1| [Comment] # Start with assignments to all the identifiers used below, so that they are
56405668
# 2| [Comment] # interpreted as variables.
56415669
# 22| [Comment] # Unary operations

ruby/ql/test/library-tests/ast/ValueText.expected

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,12 @@ exprValue
276276
| control/cases.rb:162:10:162:10 | :x | :x | symbol |
277277
| control/cases.rb:162:16:162:16 | :y | :y | symbol |
278278
| control/cases.rb:162:19:162:19 | 1 | 1 | int |
279+
| control/cases.rb:165:3:165:5 | foo | 42 | int |
280+
| control/cases.rb:166:6:166:6 | 1 | 1 | int |
281+
| control/cases.rb:166:13:166:13 | 2 | 2 | int |
282+
| control/cases.rb:170:3:170:5 | foo | 42 | int |
283+
| control/cases.rb:171:4:171:4 | 3 | 3 | int |
284+
| control/cases.rb:171:11:171:17 | "three" | three | string |
279285
| control/conditionals.rb:2:5:2:5 | 0 | 0 | int |
280286
| control/conditionals.rb:3:5:3:5 | 0 | 0 | int |
281287
| control/conditionals.rb:4:5:4:5 | 0 | 0 | int |
@@ -921,6 +927,7 @@ exprValue
921927
| operations/operations.rb:104:25:104:25 | 1 | 1 | int |
922928
| operations/operations.rb:104:28:104:28 | 2 | 2 | int |
923929
| operations/operations.rb:104:31:104:31 | 3 | 3 | int |
930+
| operations/operations.rb:107:1:107:1 | 5 | 5 | int |
924931
| params/params.rb:41:46:41:46 | 7 | 7 | int |
925932
| params/params.rb:47:19:47:21 | :bar | :bar | symbol |
926933
| params/params.rb:47:24:47:24 | 2 | 2 | int |
@@ -1184,6 +1191,12 @@ exprCfgNodeValue
11841191
| control/cases.rb:160:13:160:13 | 2 | 2 | int |
11851192
| control/cases.rb:162:1:162:20 | nil | nil | nil |
11861193
| control/cases.rb:162:19:162:19 | 1 | 1 | int |
1194+
| control/cases.rb:165:3:165:5 | foo | 42 | int |
1195+
| control/cases.rb:166:6:166:6 | 1 | 1 | int |
1196+
| control/cases.rb:166:13:166:13 | 2 | 2 | int |
1197+
| control/cases.rb:170:3:170:5 | foo | 42 | int |
1198+
| control/cases.rb:171:4:171:4 | 3 | 3 | int |
1199+
| control/cases.rb:171:11:171:17 | "three" | three | string |
11871200
| control/conditionals.rb:2:5:2:5 | 0 | 0 | int |
11881201
| control/conditionals.rb:3:5:3:5 | 0 | 0 | int |
11891202
| control/conditionals.rb:4:5:4:5 | 0 | 0 | int |
@@ -1828,6 +1841,7 @@ exprCfgNodeValue
18281841
| operations/operations.rb:104:25:104:25 | 1 | 1 | int |
18291842
| operations/operations.rb:104:28:104:28 | 2 | 2 | int |
18301843
| operations/operations.rb:104:31:104:31 | 3 | 3 | int |
1844+
| operations/operations.rb:107:1:107:1 | 5 | 5 | int |
18311845
| params/params.rb:41:46:41:46 | 7 | 7 | int |
18321846
| params/params.rb:47:19:47:21 | :bar | :bar | symbol |
18331847
| params/params.rb:47:24:47:24 | 2 | 2 | int |

ruby/ql/test/library-tests/ast/control/CaseExpr.expected

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ caseValues
1212
| cases.rb:154:1:158:3 | case ... | cases.rb:154:6:154:9 | call to expr |
1313
| cases.rb:160:1:160:14 | case ... | cases.rb:160:1:160:4 | call to expr |
1414
| cases.rb:162:1:162:20 | case ... | cases.rb:162:1:162:4 | call to expr |
15+
| cases.rb:164:1:167:3 | case ... | cases.rb:165:3:165:5 | foo |
16+
| cases.rb:169:1:172:3 | case ... | cases.rb:170:3:170:5 | foo |
1517
caseNoValues
1618
| cases.rb:18:1:22:3 | case ... |
1719
caseElseBranches
@@ -30,13 +32,16 @@ caseNoElseBranches
3032
| cases.rb:147:1:152:3 | case ... |
3133
| cases.rb:154:1:158:3 | case ... |
3234
| cases.rb:162:1:162:20 | case ... |
35+
| cases.rb:164:1:167:3 | case ... |
36+
| cases.rb:169:1:172:3 | case ... |
3337
caseWhenBranches
3438
| cases.rb:8:1:15:3 | case ... | cases.rb:9:1:10:7 | when ... | 0 | cases.rb:9:6:9:6 | b | cases.rb:9:7:10:7 | then ... |
3539
| cases.rb:8:1:15:3 | case ... | cases.rb:11:1:12:7 | when ... | 0 | cases.rb:11:6:11:6 | c | cases.rb:11:10:12:7 | then ... |
3640
| cases.rb:8:1:15:3 | case ... | cases.rb:11:1:12:7 | when ... | 1 | cases.rb:11:9:11:9 | d | cases.rb:11:10:12:7 | then ... |
3741
| cases.rb:18:1:22:3 | case ... | cases.rb:19:1:19:19 | when ... | 0 | cases.rb:19:6:19:10 | ... > ... | cases.rb:19:13:19:19 | then ... |
3842
| cases.rb:18:1:22:3 | case ... | cases.rb:20:1:20:19 | when ... | 0 | cases.rb:20:6:20:11 | ... == ... | cases.rb:20:13:20:19 | then ... |
3943
| cases.rb:18:1:22:3 | case ... | cases.rb:21:1:21:19 | when ... | 0 | cases.rb:21:6:21:10 | ... < ... | cases.rb:21:13:21:19 | then ... |
44+
| cases.rb:164:1:167:3 | case ... | cases.rb:166:1:166:13 | when ... | 0 | cases.rb:166:6:166:6 | 1 | cases.rb:166:8:166:13 | then ... |
4045
caseAllBranches
4146
| cases.rb:8:1:15:3 | case ... | 0 | cases.rb:9:1:10:7 | when ... |
4247
| cases.rb:8:1:15:3 | case ... | 1 | cases.rb:11:1:12:7 | when ... |
@@ -139,3 +144,5 @@ caseAllBranches
139144
| cases.rb:160:1:160:14 | case ... | 0 | cases.rb:160:1:160:14 | in ... then ... |
140145
| cases.rb:160:1:160:14 | case ... | 1 | cases.rb:160:1:160:14 | else ... |
141146
| cases.rb:162:1:162:20 | case ... | 0 | cases.rb:162:1:162:20 | in ... then ... |
147+
| cases.rb:164:1:167:3 | case ... | 0 | cases.rb:166:1:166:13 | when ... |
148+
| cases.rb:169:1:172:3 | case ... | 0 | cases.rb:171:1:171:17 | in ... then ... |

ruby/ql/test/library-tests/ast/control/ControlExpr.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
| cases.rb:154:1:158:3 | case ... | CaseExpr |
1313
| cases.rb:160:1:160:14 | case ... | CaseExpr |
1414
| cases.rb:162:1:162:20 | case ... | CaseExpr |
15+
| cases.rb:164:1:167:3 | case ... | CaseExpr |
16+
| cases.rb:169:1:172:3 | case ... | CaseExpr |
1517
| conditionals.rb:10:1:12:3 | if ... | IfExpr |
1618
| conditionals.rb:15:1:19:3 | if ... | IfExpr |
1719
| conditionals.rb:22:1:30:3 | if ... | IfExpr |

ruby/ql/test/library-tests/ast/control/cases.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,14 @@
159159

160160
expr in [1, 2]
161161

162-
expr => {x: v, y: 1}
162+
expr => {x: v, y: 1}
163+
164+
case
165+
foo
166+
when 1 then 2
167+
end
168+
169+
case
170+
foo
171+
in 3 then "three"
172+
end

ruby/ql/test/library-tests/ast/operations/binary.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ binaryOperations
4545
| operations.rb:101:21:101:23 | ... \|\| ... | \|\| | operations.rb:101:1:101:19 | MemberConstant | operations.rb:101:25:101:25 | 8 | LogicalOrExpr |
4646
| operations.rb:102:27:102:29 | ... \|\| ... | \|\| | operations.rb:102:1:102:25 | OtherConstant | operations.rb:102:31:102:31 | 7 | LogicalOrExpr |
4747
| operations.rb:103:13:103:15 | ... \|\| ... | \|\| | operations.rb:103:1:103:11 | CONSTANT4 | operations.rb:103:17:103:17 | 7 | LogicalOrExpr |
48+
| operations.rb:106:1:107:1 | ... / ... | / | operations.rb:106:1:106:3 | foo | operations.rb:107:1:107:1 | 5 | DivExpr |
4849
binaryArithmeticOperations
4950
| operations.rb:32:1:32:7 | ... + ... | + | operations.rb:32:1:32:1 | w | operations.rb:32:5:32:7 | 234 | AddExpr |
5051
| operations.rb:33:1:33:6 | ... - ... | - | operations.rb:33:1:33:1 | x | operations.rb:33:5:33:6 | 17 | SubExpr |
@@ -62,6 +63,7 @@ binaryArithmeticOperations
6263
| operations.rb:92:7:92:8 | ... / ... | / | operations.rb:92:3:92:5 | @@y | operations.rb:92:10:92:10 | 4 | DivExpr |
6364
| operations.rb:96:13:96:14 | ... * ... | * | operations.rb:96:1:96:11 | $global_var | operations.rb:96:16:96:16 | 6 | MulExpr |
6465
| operations.rb:99:11:99:12 | ... + ... | + | operations.rb:99:1:99:9 | CONSTANT2 | operations.rb:99:14:99:14 | 6 | AddExpr |
66+
| operations.rb:106:1:107:1 | ... / ... | / | operations.rb:106:1:106:3 | foo | operations.rb:107:1:107:1 | 5 | DivExpr |
6567
binaryLogicalOperations
6668
| operations.rb:40:1:40:10 | ... && ... | && | operations.rb:40:1:40:3 | foo | operations.rb:40:8:40:10 | bar | LogicalAndExpr |
6769
| operations.rb:41:1:41:11 | ... and ... | and | operations.rb:41:1:41:3 | baz | operations.rb:41:9:41:11 | qux | LogicalAndExpr |

ruby/ql/test/library-tests/ast/operations/operation.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,5 @@
243243
| operations.rb:104:24:104:32 | * ... | * | operations.rb:104:24:104:32 | [...] | SplatExpr |
244244
| operations.rb:104:24:104:32 | ... = ... | = | operations.rb:104:24:104:32 | * ... | AssignExpr |
245245
| operations.rb:104:24:104:32 | ... = ... | = | operations.rb:104:24:104:32 | __synth__3 | AssignExpr |
246+
| operations.rb:106:1:107:1 | ... / ... | / | operations.rb:106:1:106:3 | foo | DivExpr |
247+
| operations.rb:106:1:107:1 | ... / ... | / | operations.rb:107:1:107:1 | 5 | DivExpr |

ruby/ql/test/library-tests/ast/operations/operations.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,6 @@ class X
102102
foo(1).bar::OtherConstant ||= 7
103103
::CONSTANT4 ||= 7
104104
FOO, ::BAR, foo::FOO = [1, 2, 3]
105+
106+
foo /
107+
5

0 commit comments

Comments
 (0)
0