Skip to content

Commit 3c15fd2

Browse files
committed
Ruby: add one-line pattern match test
1 parent edbba85 commit 3c15fd2

File tree

7 files changed

+51
-7
lines changed

7 files changed

+51
-7
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,22 @@ control/cases.rb:
12591259
# 157| getExpr: [AddExpr] ... + ...
12601260
# 157| getAnOperand/getLeftOperand/getReceiver: [IntegerLiteral] 1
12611261
# 157| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 1
1262+
# 160| getStmt: [TestPattern] ... in ...
1263+
# 160| getValue: [MethodCall] call to expr
1264+
# 160| getReceiver: [SelfVariableAccess] self
1265+
# 160| getPattern: [ArrayPattern] [ ..., * ]
1266+
# 160| getPrefixElement: [IntegerLiteral] 1
1267+
# 160| getPrefixElement: [IntegerLiteral] 2
1268+
# 162| getStmt: [MatchPattern] ... => ...
1269+
# 162| getValue: [MethodCall] call to expr
1270+
# 162| getReceiver: [SelfVariableAccess] self
1271+
# 162| getPattern: [HashPattern] { ..., ** }
1272+
# 162| getKey: [SymbolLiteral] :x
1273+
# 162| getComponent: [StringTextComponent] x
1274+
# 162| getValue: [LocalVariableAccess] v
1275+
# 162| getKey: [SymbolLiteral] :y
1276+
# 162| getComponent: [StringTextComponent] y
1277+
# 162| getValue: [IntegerLiteral] 1
12621278
modules/classes.rb:
12631279
# 2| [Toplevel] classes.rb
12641280
# 3| getStmt: [ClassDeclaration] Foo

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,6 +2732,30 @@ control/cases.rb:
27322732
# 157| 3: [ReservedWord] )
27332733
# 157| 2: [ReservedWord] ;
27342734
# 158| 5: [ReservedWord] end
2735+
# 160| 17: [TestPattern] TestPattern
2736+
# 160| 0: [Identifier] expr
2737+
# 160| 1: [ReservedWord] in
2738+
# 160| 2: [ArrayPattern] ArrayPattern
2739+
# 160| 0: [ReservedWord] [
2740+
# 160| 1: [Integer] 1
2741+
# 160| 2: [ReservedWord] ,
2742+
# 160| 3: [Integer] 2
2743+
# 160| 4: [ReservedWord] ]
2744+
# 162| 18: [MatchPattern] MatchPattern
2745+
# 162| 0: [Identifier] expr
2746+
# 162| 1: [ReservedWord] =>
2747+
# 162| 2: [HashPattern] HashPattern
2748+
# 162| 0: [ReservedWord] {
2749+
# 162| 1: [KeywordPattern] KeywordPattern
2750+
# 162| 0: [HashKeySymbol] x
2751+
# 162| 1: [ReservedWord] :
2752+
# 162| 2: [Identifier] v
2753+
# 162| 2: [ReservedWord] ,
2754+
# 162| 3: [KeywordPattern] KeywordPattern
2755+
# 162| 0: [HashKeySymbol] y
2756+
# 162| 1: [ReservedWord] :
2757+
# 162| 2: [Integer] 1
2758+
# 162| 4: [ReservedWord] }
27352759
# 1| [Comment] # Define some variables used below
27362760
# 7| [Comment] # A case expr with a value and an else branch
27372761
# 17| [Comment] # A case expr without a value or else branch

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ exprValue
263263
| control/cases.rb:157:8:157:8 | 1 | 1 | int |
264264
| control/cases.rb:157:8:157:12 | ... + ... | 2 | int |
265265
| control/cases.rb:157:12:157:12 | 1 | 1 | int |
266+
| control/cases.rb:160:10:160:10 | 1 | 1 | int |
267+
| control/cases.rb:160:13:160:13 | 2 | 2 | int |
268+
| control/cases.rb:162:10:162:10 | :x | :x | symbol |
269+
| control/cases.rb:162:16:162:16 | :y | :y | symbol |
270+
| control/cases.rb:162:19:162:19 | 1 | 1 | int |
266271
| control/conditionals.rb:2:5:2:5 | 0 | 0 | int |
267272
| control/conditionals.rb:3:5:3:5 | 0 | 0 | int |
268273
| control/conditionals.rb:4:5:4:5 | 0 | 0 | int |

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,8 @@
155155
in ^(foo);
156156
in ^(@foo);
157157
in ^(1 + 1);
158-
end
158+
end
159+
160+
expr in [1, 2]
161+
162+
expr => {x: v, y: 1}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
| src/not_ruby.rb:5:25:5:26 | parse error | Extraction failed in src/not_ruby.rb with error parse error | 2 |
2-
| src/unsupported_feature.rb:2:1:2:4 | parse error | Extraction failed in src/unsupported_feature.rb with error parse error | 2 |
3-
| src/unsupported_feature.rb:3:1:3:8 | parse error | Extraction failed in src/unsupported_feature.rb with error parse error | 2 |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| 2 |
1+
| 1 |

ruby/ql/test/query-tests/diagnostics/src/unsupported_feature.rb

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)