Skip to content

Commit a27d20d

Browse files
committed
Rust: Add test cases for binary operator at start of line
1 parent 76ed386 commit a27d20d

File tree

6 files changed

+91
-0
lines changed

6 files changed

+91
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,24 @@ control/conditionals.rb:
14581458
# 67| getBranch/getThen: [StmtSequence] then ...
14591459
# 68| getBranch/getElse: [StmtSequence] else ...
14601460
# 69| getStmt: [LocalVariableAccess] c
1461+
# 73| getStmt: [IfExpr] if ...
1462+
# 73| getCondition: [LogicalAndExpr] ... && ...
1463+
# 73| getAnOperand/getLeftOperand/getReceiver: [LocalVariableAccess] a
1464+
# 73| getAnOperand/getArgument/getRightOperand: [LocalVariableAccess] b
1465+
# 73| getBranch/getThen: [StmtSequence] then ...
1466+
# 74| getStmt: [LocalVariableAccess] c
1467+
# 78| getStmt: [IfExpr] if ...
1468+
# 78| getCondition: [LogicalAndExpr] ... && ...
1469+
# 78| getAnOperand/getLeftOperand/getReceiver: [LocalVariableAccess] a
1470+
# 79| getAnOperand/getArgument/getRightOperand: [LocalVariableAccess] b
1471+
# 79| getBranch/getThen: [StmtSequence] then ...
1472+
# 81| getStmt: [LocalVariableAccess] c
1473+
# 85| getStmt: [IfExpr] if ...
1474+
# 85| getCondition: [LogicalAndExpr] ... && ...
1475+
# 85| getAnOperand/getLeftOperand/getReceiver: [LocalVariableAccess] a
1476+
# 86| getAnOperand/getArgument/getRightOperand: [LocalVariableAccess] b
1477+
# 86| getBranch/getThen: [StmtSequence] then ...
1478+
# 88| getStmt: [LocalVariableAccess] c
14611479
constants/constants.rb:
14621480
# 1| [Toplevel] constants.rb
14631481
# 1| getStmt: [ModuleDeclaration] ModuleA

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2962,6 +2962,36 @@ control/conditionals.rb:
29622962
# 68| 0: [ReservedWord] else
29632963
# 69| 1: [Identifier] c
29642964
# 70| 4: [ReservedWord] end
2965+
# 73| 17: [If] If
2966+
# 73| 0: [ReservedWord] if
2967+
# 73| 1: [Binary] Binary
2968+
# 73| 0: [Identifier] a
2969+
# 73| 1: [ReservedWord] &&
2970+
# 73| 2: [Identifier] b
2971+
# 73| 2: [Then] Then
2972+
# 73| 0: [ReservedWord] then
2973+
# 74| 1: [Identifier] c
2974+
# 75| 3: [ReservedWord] end
2975+
# 78| 18: [If] If
2976+
# 78| 0: [ReservedWord] if
2977+
# 78| 1: [Binary] Binary
2978+
# 78| 0: [Identifier] a
2979+
# 79| 1: [ReservedWord] &&
2980+
# 79| 2: [Identifier] b
2981+
# 79| 2: [Then] Then
2982+
# 80| 0: [ReservedWord] then
2983+
# 81| 1: [Identifier] c
2984+
# 82| 3: [ReservedWord] end
2985+
# 85| 19: [If] If
2986+
# 85| 0: [ReservedWord] if
2987+
# 85| 1: [Binary] Binary
2988+
# 85| 0: [Identifier] a
2989+
# 85| 1: [ReservedWord] &&
2990+
# 86| 2: [Identifier] b
2991+
# 86| 2: [Then] Then
2992+
# 87| 0: [ReservedWord] then
2993+
# 88| 1: [Identifier] c
2994+
# 89| 3: [ReservedWord] end
29652995
# 1| [Comment] # Define some variables used below
29662996
# 9| [Comment] # If expr with no else
29672997
# 14| [Comment] # If expr with single else
@@ -2974,6 +3004,9 @@ control/conditionals.rb:
29743004
# 57| [Comment] # Ternary if expr
29753005
# 60| [Comment] # If expr with empty else (treated as no else)
29763006
# 66| [Comment] # If expr with empty then (treated as no then)
3007+
# 72| [Comment] # If expr with && on same line as condition and then
3008+
# 77| [Comment] # If expr with && at the start of a separate line before then
3009+
# 84| [Comment] # If expr with && at end of line
29773010
control/loops.rb:
29783011
# 1| [Program] Program
29793012
# 2| 0: [Assignment] Assignment

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,12 @@ exprValue
336336
| control/conditionals.rb:62:5:62:5 | c | 0 | int |
337337
| control/conditionals.rb:67:8:67:8 | b | 0 | int |
338338
| control/conditionals.rb:69:5:69:5 | c | 0 | int |
339+
| control/conditionals.rb:73:9:73:9 | b | 0 | int |
340+
| control/conditionals.rb:74:5:74:5 | c | 0 | int |
341+
| control/conditionals.rb:79:8:79:8 | b | 0 | int |
342+
| control/conditionals.rb:81:5:81:5 | c | 0 | int |
343+
| control/conditionals.rb:86:5:86:5 | b | 0 | int |
344+
| control/conditionals.rb:88:5:88:5 | c | 0 | int |
339345
| control/loops.rb:2:7:2:7 | 0 | 0 | int |
340346
| control/loops.rb:3:7:3:7 | 0 | 0 | int |
341347
| control/loops.rb:4:5:4:5 | 0 | 0 | int |
@@ -1257,6 +1263,12 @@ exprCfgNodeValue
12571263
| control/conditionals.rb:62:5:62:5 | c | 0 | int |
12581264
| control/conditionals.rb:67:8:67:8 | b | 0 | int |
12591265
| control/conditionals.rb:69:5:69:5 | c | 0 | int |
1266+
| control/conditionals.rb:73:9:73:9 | b | 0 | int |
1267+
| control/conditionals.rb:74:5:74:5 | c | 0 | int |
1268+
| control/conditionals.rb:79:8:79:8 | b | 0 | int |
1269+
| control/conditionals.rb:81:5:81:5 | c | 0 | int |
1270+
| control/conditionals.rb:86:5:86:5 | b | 0 | int |
1271+
| control/conditionals.rb:88:5:88:5 | c | 0 | int |
12601272
| control/loops.rb:2:7:2:7 | 0 | 0 | int |
12611273
| control/loops.rb:3:7:3:7 | 0 | 0 | int |
12621274
| control/loops.rb:4:5:4:5 | 0 | 0 | int |

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ conditionalExprs
2222
| conditionals.rb:61:1:64:3 | if ... | IfExpr | conditionals.rb:61:4:61:8 | ... > ... | conditionals.rb:63:1:63:4 | else ... | false |
2323
| conditionals.rb:67:1:70:3 | if ... | IfExpr | conditionals.rb:67:4:67:8 | ... > ... | conditionals.rb:67:10:67:13 | then ... | true |
2424
| conditionals.rb:67:1:70:3 | if ... | IfExpr | conditionals.rb:67:4:67:8 | ... > ... | conditionals.rb:68:1:69:5 | else ... | false |
25+
| conditionals.rb:73:1:75:3 | if ... | IfExpr | conditionals.rb:73:4:73:9 | ... && ... | conditionals.rb:73:11:74:5 | then ... | true |
26+
| conditionals.rb:78:1:82:3 | if ... | IfExpr | conditionals.rb:78:4:79:8 | ... && ... | conditionals.rb:79:9:81:5 | then ... | true |
27+
| conditionals.rb:85:1:89:3 | if ... | IfExpr | conditionals.rb:85:4:86:5 | ... && ... | conditionals.rb:86:6:88:5 | then ... | true |
2528
| loops.rb:9:5:9:5 | if ... | IfExpr | loops.rb:9:5:9:5 | ! ... | loops.rb:9:5:9:5 | ... = ... | true |
2629
| loops.rb:16:5:16:5 | if ... | IfExpr | loops.rb:16:5:16:5 | ! ... | loops.rb:16:5:16:5 | ... = ... | true |
2730
| loops.rb:22:5:22:7 | if ... | IfExpr | loops.rb:22:5:22:7 | ! ... | loops.rb:22:5:22:7 | ... = ... | true |
@@ -38,6 +41,9 @@ ifExprs
3841
| conditionals.rb:35:1:36:5 | elsif ... | IfExpr | conditionals.rb:35:7:35:12 | ... == ... | conditionals.rb:35:13:36:5 | then ... | (none) | true |
3942
| conditionals.rb:61:1:64:3 | if ... | IfExpr | conditionals.rb:61:4:61:8 | ... > ... | conditionals.rb:61:10:62:5 | then ... | else ... | false |
4043
| conditionals.rb:67:1:70:3 | if ... | IfExpr | conditionals.rb:67:4:67:8 | ... > ... | conditionals.rb:67:10:67:13 | then ... | else ... | false |
44+
| conditionals.rb:73:1:75:3 | if ... | IfExpr | conditionals.rb:73:4:73:9 | ... && ... | conditionals.rb:73:11:74:5 | then ... | (none) | false |
45+
| conditionals.rb:78:1:82:3 | if ... | IfExpr | conditionals.rb:78:4:79:8 | ... && ... | conditionals.rb:79:9:81:5 | then ... | (none) | false |
46+
| conditionals.rb:85:1:89:3 | if ... | IfExpr | conditionals.rb:85:4:86:5 | ... && ... | conditionals.rb:86:6:88:5 | then ... | (none) | false |
4147
unlessExprs
4248
| conditionals.rb:40:1:42:3 | unless ... | UnlessExpr | conditionals.rb:40:8:40:12 | ... > ... | conditionals.rb:40:14:41:5 | then ... | (none) |
4349
| conditionals.rb:45:1:49:3 | unless ... | UnlessExpr | conditionals.rb:45:8:45:13 | ... == ... | conditionals.rb:45:14:46:5 | then ... | else ... |

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
| conditionals.rb:58:5:58:25 | ... ? ... : ... | TernaryIfExpr |
2929
| conditionals.rb:61:1:64:3 | if ... | IfExpr |
3030
| conditionals.rb:67:1:70:3 | if ... | IfExpr |
31+
| conditionals.rb:73:1:75:3 | if ... | IfExpr |
32+
| conditionals.rb:78:1:82:3 | if ... | IfExpr |
33+
| conditionals.rb:85:1:89:3 | if ... | IfExpr |
3134
| loops.rb:9:1:12:3 | for ... in ... | ForExpr |
3235
| loops.rb:9:5:9:5 | if ... | IfExpr |
3336
| loops.rb:16:1:19:3 | for ... in ... | ForExpr |

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,23 @@
6767
if a > b then
6868
else
6969
c
70+
end
71+
72+
# If expr with && on same line as condition and then
73+
if a && b then
74+
c
75+
end
76+
77+
# If expr with && at the start of a separate line before then
78+
if a
79+
&& b
80+
then
81+
c
82+
end
83+
84+
# If expr with && at end of line
85+
if a &&
86+
b
87+
then
88+
c
7089
end

0 commit comments

Comments
 (0)