Skip to content

Commit 3b6e588

Browse files
committed
Update constants.rb test
1 parent 0eae89a commit 3b6e588

3 files changed

Lines changed: 97 additions & 68 deletions

File tree

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

Lines changed: 63 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -803,53 +803,70 @@ constants/constants.rb:
803803
# 1| [Toplevel] constants.rb
804804
# 1| getStmt: [ModuleDeclaration] ModuleA
805805
# 2| getStmt: [ClassDeclaration] ClassA
806-
# 5| getStmt: [ModuleDeclaration] ModuleB
807-
# 6| getStmt: [ClassDeclaration] ClassB
808-
# 6| getSuperclassExpr: [ConstantReadAccess] Base
809-
# 9| getStmt: [ClassDeclaration] ClassC
810-
# 9| getSuperclassExpr: [ConstantReadAccess] Z
811-
# 9| getScopeExpr: [ConstantReadAccess] Y
812-
# 9| getScopeExpr: [ConstantReadAccess] X
813-
# 14| getStmt: [AssignExpr] ... = ...
814-
# 14| getAnOperand/getLeftOperand: [ConstantAssignment] GREETING
815-
# 14| getAnOperand/getRightOperand: [StringLiteral] "Hello"
816-
# 14| getComponent: [StringTextComponent] Hello
817-
# 16| getStmt: [Method] foo
818-
# 17| getStmt: [AssignExpr] ... = ...
819-
# 17| getAnOperand/getLeftOperand: [ConstantAssignment] Names
820-
# 17| getAnOperand/getRightOperand: [ArrayLiteral] [...]
821-
# 17| getElement: [StringLiteral] "Vera"
822-
# 17| getComponent: [StringTextComponent] Vera
823-
# 17| getElement: [StringLiteral] "Chuck"
824-
# 17| getComponent: [StringTextComponent] Chuck
825-
# 17| getElement: [StringLiteral] "Dave"
826-
# 17| getComponent: [StringTextComponent] Dave
827-
# 19| getStmt: [MethodCall] call to each
828-
# 19| getReceiver: [ConstantReadAccess] Names
829-
# 19| getBlock: [DoBlock] do ... end
830-
# 19| getParameter: [SimpleParameter] name
831-
# 19| getDefiningAccess: [LocalVariableAccess] name
832-
# 20| getStmt: [MethodCall] call to puts
833-
# 20| getReceiver: [Self] self
834-
# 20| getArgument: [StringLiteral] "#{...} #{...}"
835-
# 20| getComponent: [StringInterpolationComponent] #{...}
836-
# 20| getStmt: [ConstantReadAccess] GREETING
837-
# 20| getComponent: [StringTextComponent]
838-
# 20| getComponent: [StringInterpolationComponent] #{...}
839-
# 20| getStmt: [LocalVariableAccess] name
840-
# 25| getStmt: [MethodCall] call to Array
841-
# 25| getReceiver: [Self] self
842-
# 25| getArgument: [StringLiteral] "foo"
843-
# 25| getComponent: [StringTextComponent] foo
844-
# 28| getStmt: [ClassDeclaration] ClassD
845-
# 28| getScopeExpr: [ConstantReadAccess] ModuleA
846-
# 31| getStmt: [ModuleDeclaration] ModuleC
806+
# 3| getStmt: [AssignExpr] ... = ...
807+
# 3| getAnOperand/getLeftOperand: [ConstantAssignment] CONST_A
808+
# 3| getAnOperand/getRightOperand: [StringLiteral] "const_a"
809+
# 3| getComponent: [StringTextComponent] const_a
810+
# 6| getStmt: [AssignExpr] ... = ...
811+
# 6| getAnOperand/getLeftOperand: [ConstantAssignment] CONST_B
812+
# 6| getAnOperand/getRightOperand: [StringLiteral] "const_b"
813+
# 6| getComponent: [StringTextComponent] const_b
814+
# 8| getStmt: [ModuleDeclaration] ModuleB
815+
# 9| getStmt: [ClassDeclaration] ClassB
816+
# 9| getSuperclassExpr: [ConstantReadAccess] Base
817+
# 12| getStmt: [ClassDeclaration] ClassC
818+
# 12| getSuperclassExpr: [ConstantReadAccess] Z
819+
# 12| getScopeExpr: [ConstantReadAccess] Y
820+
# 12| getScopeExpr: [ConstantReadAccess] X
821+
# 17| getStmt: [AssignExpr] ... = ...
822+
# 17| getAnOperand/getLeftOperand: [ConstantAssignment] GREETING
823+
# 17| getAnOperand/getRightOperand: [AddExpr] ... + ...
824+
# 17| getAnOperand/getLeftOperand: [AddExpr] ... + ...
825+
# 17| getAnOperand/getLeftOperand: [StringLiteral] "Hello"
826+
# 17| getComponent: [StringTextComponent] Hello
827+
# 17| getAnOperand/getRightOperand: [ConstantReadAccess] CONST_A
828+
# 17| getScopeExpr: [ConstantReadAccess] ClassA
829+
# 17| getScopeExpr: [ConstantReadAccess] ModuleA
830+
# 17| getAnOperand/getRightOperand: [ConstantReadAccess] CONST_B
831+
# 17| getScopeExpr: [ConstantReadAccess] ModuleA
832+
# 19| getStmt: [Method] foo
833+
# 20| getStmt: [AssignExpr] ... = ...
834+
# 20| getAnOperand/getLeftOperand: [ConstantAssignment] Names
835+
# 20| getAnOperand/getRightOperand: [ArrayLiteral] [...]
836+
# 20| getElement: [StringLiteral] "Vera"
837+
# 20| getComponent: [StringTextComponent] Vera
838+
# 20| getElement: [StringLiteral] "Chuck"
839+
# 20| getComponent: [StringTextComponent] Chuck
840+
# 20| getElement: [StringLiteral] "Dave"
841+
# 20| getComponent: [StringTextComponent] Dave
842+
# 22| getStmt: [MethodCall] call to each
843+
# 22| getReceiver: [ConstantReadAccess] Names
844+
# 22| getBlock: [DoBlock] do ... end
845+
# 22| getParameter: [SimpleParameter] name
846+
# 22| getDefiningAccess: [LocalVariableAccess] name
847+
# 23| getStmt: [MethodCall] call to puts
848+
# 23| getReceiver: [Self] self
849+
# 23| getArgument: [StringLiteral] "#{...} #{...}"
850+
# 23| getComponent: [StringInterpolationComponent] #{...}
851+
# 23| getStmt: [ConstantReadAccess] GREETING
852+
# 23| getComponent: [StringTextComponent]
853+
# 23| getComponent: [StringInterpolationComponent] #{...}
854+
# 23| getStmt: [LocalVariableAccess] name
855+
# 28| getStmt: [MethodCall] call to Array
856+
# 28| getReceiver: [Self] self
857+
# 28| getArgument: [StringLiteral] "foo"
858+
# 28| getComponent: [StringTextComponent] foo
859+
# 31| getStmt: [ClassDeclaration] ClassD
847860
# 31| getScopeExpr: [ConstantReadAccess] ModuleA
848-
# 34| getStmt: [AssignExpr] ... = ...
849-
# 34| getAnOperand/getLeftOperand: [ConstantAssignment] MAX_SIZE
850-
# 34| getScopeExpr: [ConstantReadAccess] ModuleB
851-
# 34| getScopeExpr: [ConstantReadAccess] ModuleA
852-
# 34| getAnOperand/getRightOperand: [IntegerLiteral] 1024
861+
# 31| getSuperclassExpr: [ConstantReadAccess] ClassA
862+
# 31| getScopeExpr: [ConstantReadAccess] ModuleA
863+
# 34| getStmt: [ModuleDeclaration] ModuleC
864+
# 34| getScopeExpr: [ConstantReadAccess] ModuleA
865+
# 37| getStmt: [AssignExpr] ... = ...
866+
# 37| getAnOperand/getLeftOperand: [ConstantAssignment] MAX_SIZE
867+
# 37| getScopeExpr: [ConstantReadAccess] ModuleB
868+
# 37| getScopeExpr: [ConstantReadAccess] ModuleA
869+
# 37| getAnOperand/getRightOperand: [IntegerLiteral] 1024
853870
literals/literals.rb:
854871
# 1| [Toplevel] literals.rb
855872
# 2| getStmt: [NilLiteral] nil
Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1-
| constants.rb:1:1:12:3 | ModuleA | write | ModuleA | ModuleDeclaration |
2-
| constants.rb:2:5:3:7 | ClassA | write | ClassA | ClassDeclaration |
3-
| constants.rb:5:5:11:7 | ModuleB | write | ModuleB | ModuleDeclaration |
4-
| constants.rb:6:9:7:11 | ClassB | write | ClassB | ClassDeclaration |
5-
| constants.rb:6:24:6:27 | Base | read | Base | ConstantReadAccess |
6-
| constants.rb:9:9:10:11 | ClassC | write | ClassC | ClassDeclaration |
7-
| constants.rb:9:24:9:24 | X | read | X | ConstantReadAccess |
8-
| constants.rb:9:24:9:27 | Y | read | Y | ConstantReadAccess |
9-
| constants.rb:9:24:9:30 | Z | read | Z | ConstantReadAccess |
10-
| constants.rb:14:1:14:8 | GREETING | write | GREETING | ConstantAssignment |
11-
| constants.rb:17:5:17:9 | Names | write | Names | ConstantAssignment |
12-
| constants.rb:19:5:19:9 | Names | read | Names | ConstantReadAccess |
13-
| constants.rb:20:18:20:25 | GREETING | read | GREETING | ConstantReadAccess |
14-
| constants.rb:28:1:29:3 | ClassD | write | ClassD | ClassDeclaration |
15-
| constants.rb:28:7:28:13 | ModuleA | read | ModuleA | ConstantReadAccess |
16-
| constants.rb:31:1:32:3 | ModuleC | write | ModuleC | ModuleDeclaration |
17-
| constants.rb:31:8:31:14 | ModuleA | read | ModuleA | ConstantReadAccess |
18-
| constants.rb:34:1:34:7 | ModuleA | read | ModuleA | ConstantReadAccess |
19-
| constants.rb:34:1:34:16 | ModuleB | read | ModuleB | ConstantReadAccess |
20-
| constants.rb:34:1:34:26 | MAX_SIZE | write | MAX_SIZE | ConstantAssignment |
1+
| constants.rb:1:1:15:3 | ModuleA | write | ModuleA | ModuleDeclaration |
2+
| constants.rb:2:5:4:7 | ClassA | write | ClassA | ClassDeclaration |
3+
| constants.rb:3:9:3:15 | CONST_A | write | CONST_A | ConstantAssignment |
4+
| constants.rb:6:5:6:11 | CONST_B | write | CONST_B | ConstantAssignment |
5+
| constants.rb:8:5:14:7 | ModuleB | write | ModuleB | ModuleDeclaration |
6+
| constants.rb:9:9:10:11 | ClassB | write | ClassB | ClassDeclaration |
7+
| constants.rb:9:24:9:27 | Base | read | Base | ConstantReadAccess |
8+
| constants.rb:12:9:13:11 | ClassC | write | ClassC | ClassDeclaration |
9+
| constants.rb:12:24:12:24 | X | read | X | ConstantReadAccess |
10+
| constants.rb:12:24:12:27 | Y | read | Y | ConstantReadAccess |
11+
| constants.rb:12:24:12:30 | Z | read | Z | ConstantReadAccess |
12+
| constants.rb:17:1:17:8 | GREETING | write | GREETING | ConstantAssignment |
13+
| constants.rb:17:22:17:28 | ModuleA | read | ModuleA | ConstantReadAccess |
14+
| constants.rb:17:22:17:36 | ClassA | read | ClassA | ConstantReadAccess |
15+
| constants.rb:17:22:17:45 | CONST_A | read | CONST_A | ConstantReadAccess |
16+
| constants.rb:17:49:17:55 | ModuleA | read | ModuleA | ConstantReadAccess |
17+
| constants.rb:17:49:17:64 | CONST_B | read | CONST_B | ConstantReadAccess |
18+
| constants.rb:20:5:20:9 | Names | write | Names | ConstantAssignment |
19+
| constants.rb:22:5:22:9 | Names | read | Names | ConstantReadAccess |
20+
| constants.rb:23:18:23:25 | GREETING | read | GREETING | ConstantReadAccess |
21+
| constants.rb:31:1:32:3 | ClassD | write | ClassD | ClassDeclaration |
22+
| constants.rb:31:7:31:13 | ModuleA | read | ModuleA | ConstantReadAccess |
23+
| constants.rb:31:25:31:31 | ModuleA | read | ModuleA | ConstantReadAccess |
24+
| constants.rb:31:25:31:39 | ClassA | read | ClassA | ConstantReadAccess |
25+
| constants.rb:34:1:35:3 | ModuleC | write | ModuleC | ModuleDeclaration |
26+
| constants.rb:34:8:34:14 | ModuleA | read | ModuleA | ConstantReadAccess |
27+
| constants.rb:37:1:37:7 | ModuleA | read | ModuleA | ConstantReadAccess |
28+
| constants.rb:37:1:37:16 | ModuleB | read | ModuleB | ConstantReadAccess |
29+
| constants.rb:37:1:37:26 | MAX_SIZE | write | MAX_SIZE | ConstantAssignment |

ql/test/library-tests/ast/constants/constants.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
module ModuleA
22
class ClassA
3+
CONST_A = "const_a"
34
end
45

6+
CONST_B = "const_b"
7+
58
module ModuleB
69
class ClassB < Base
710
end
@@ -11,7 +14,7 @@ class ClassC < X::Y::Z
1114
end
1215
end
1316

14-
GREETING = 'Hello'
17+
GREETING = 'Hello' + ModuleA::ClassA::CONST_A + ModuleA::CONST_B
1518

1619
def foo
1720
Names = ['Vera', 'Chuck', 'Dave']
@@ -25,7 +28,7 @@ def foo
2528
Array('foo')
2629
end
2730

28-
class ModuleA::ClassD
31+
class ModuleA::ClassD < ModuleA::ClassA
2932
end
3033

3134
module ModuleA::ModuleC

0 commit comments

Comments
 (0)