Skip to content

Commit 9f12660

Browse files
committed
[GR-45043] Add unit tests for the parser
PullRequest: truffleruby/3814
2 parents e0b08dd + a1b556f commit 9f12660

File tree

373 files changed

+26984
-25
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

373 files changed

+26984
-25
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
subject: "BEGIN block"
2+
description: "BEGIN { ... }"
3+
focused_on_node: "org.truffleruby.language.control.SequenceNode"
4+
ruby: |
5+
BEGIN {
6+
1
7+
2
8+
}
9+
ast: |
10+
SequenceNode
11+
attributes:
12+
flags = 12
13+
children:
14+
body = [
15+
EmitWarningsNode
16+
attributes:
17+
flags = 0
18+
warnings = org.truffleruby.parser.RubyDeferredWarnings@...
19+
WriteLocalVariableNode
20+
attributes:
21+
flags = 0
22+
frameSlot = 0
23+
children:
24+
valueNode =
25+
ProfileArgumentNodeGen
26+
attributes:
27+
flags = 0
28+
children:
29+
childNode_ =
30+
ReadSelfNode
31+
attributes:
32+
flags = 0
33+
IntegerFixnumLiteralNode
34+
attributes:
35+
flags = 1
36+
value = 1
37+
IntegerFixnumLiteralNode
38+
attributes:
39+
flags = 1
40+
value = 2
41+
NilLiteralNode
42+
attributes:
43+
flags = 0
44+
isImplicit = false
45+
]
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
subject: "END block"
2+
description: "END { ... }"
3+
notes: >
4+
Is trasnalted into a `Truffle::KernelOperations.at_exit(false) { ... }` call.
5+
focused_on_node: "org.truffleruby.language.control.OnceNode"
6+
ruby: |
7+
END {
8+
1
9+
2
10+
}
11+
ast: |
12+
OnceNode
13+
attributes:
14+
flags = 0
15+
holder = org.truffleruby.language.control.OnceNode$Holder@...
16+
children:
17+
child =
18+
CatchBreakNode
19+
attributes:
20+
breakID = org.truffleruby.language.control.BreakID@...
21+
flags = 0
22+
isWhile = false
23+
children:
24+
body =
25+
FrameOnStackNode
26+
attributes:
27+
flags = 0
28+
frameOnStackMarkerSlot = 2
29+
children:
30+
child =
31+
RubyCallNode
32+
attributes:
33+
descriptor = org.truffleruby.language.arguments.EmptyArgumentsDescriptor@...
34+
dispatchConfig = PROTECTED
35+
emptyKeywordsProfile = false
36+
flags = 0
37+
isAttrAssign = false
38+
isSafeNavigation = false
39+
isSplatted = false
40+
isVCall = false
41+
lastArgIsNotHashProfile = false
42+
methodName = "at_exit"
43+
notEmptyKeywordsProfile = false
44+
notRuby2KeywordsHashProfile = false
45+
ruby2KeywordsHashProfile = false
46+
children:
47+
arguments = [
48+
BooleanLiteralNode
49+
attributes:
50+
flags = 0
51+
value = false
52+
]
53+
block =
54+
BlockDefinitionNode
55+
attributes:
56+
breakID = org.truffleruby.language.control.BreakID@...
57+
callTargets = ProcCallTargets(callTargetForProc = block in <top (required)>, callTargetForLambda = null, altCallTargetCompiler = org.truffleruby.parser.MethodTranslator$$Lambda$.../0x...@...)
58+
flags = 0
59+
frameOnStackMarkerSlot = 2
60+
sharedMethodInfo = SharedMethodInfo(sourceSection = SourceSection(source=<parse_ast> [1 - 1], index=0, length=5, characters=END {), staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = false}, originName = block in <top (required)>, blockDepth = 1, parseName = block in <top (required)>, notes = <top (required)>, argumentDescriptors = [])
61+
type = PROC
62+
children:
63+
readSpecialVariableStorageNode =
64+
TruffleKernelNodesFactory$GetSpecialVariableStorageNodeGen
65+
call targets:
66+
RubyProcRootNode
67+
attributes:
68+
callTarget = block in <top (required)>
69+
frameDescriptor = FrameDescriptor@...{#0:(self)}
70+
instrumentationBits = 0
71+
lock = java.util.concurrent.locks.ReentrantLock@...[Unlocked]
72+
nextProfile = false
73+
polyglotRef = org.truffleruby.RubyLanguage@...
74+
redoProfile = false
75+
retryProfile = false
76+
returnID = org.truffleruby.language.control.ReturnID@...
77+
sharedMethodInfo = SharedMethodInfo(sourceSection = SourceSection(source=<parse_ast> [1 - 1], index=0, length=5, characters=END {), staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = false}, originName = block in <top (required)>, blockDepth = 1, parseName = block in <top (required)>, notes = <top (required)>, argumentDescriptors = [])
78+
sourceSection = SourceSection(source=<parse_ast> [1 - 1], index=0, length=5, characters=END {)
79+
split = HEURISTIC
80+
children:
81+
body =
82+
SequenceNode
83+
attributes:
84+
flags = 12
85+
children:
86+
body = [
87+
WriteLocalVariableNode
88+
attributes:
89+
flags = 0
90+
frameSlot = 0
91+
children:
92+
valueNode =
93+
ProfileArgumentNodeGen
94+
attributes:
95+
flags = 0
96+
children:
97+
childNode_ =
98+
ReadSelfNode
99+
attributes:
100+
flags = 0
101+
IntegerFixnumLiteralNode
102+
attributes:
103+
flags = 1
104+
value = 1
105+
IntegerFixnumLiteralNode
106+
attributes:
107+
flags = 1
108+
value = 2
109+
]
110+
receiver =
111+
TruffleKernelOperationsModuleLiteralNode
112+
attributes:
113+
flags = 0
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
subject: "Encoding keyword"
2+
description: "__ENCODING__ keyword"
3+
focused_on_node: "org.truffleruby.language.literal.ObjectLiteralNode"
4+
ruby: |
5+
__ENCODING__
6+
ast: |
7+
ObjectLiteralNode
8+
attributes:
9+
flags = 1
10+
object = UTF-8
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
subject: "Alias"
2+
description: "alias (dynamic) Symbols"
3+
focused_on_node: "org.truffleruby.core.module.ModuleNodes$AliasKeywordNode"
4+
ruby: |
5+
alias :"a" :"b"
6+
ast: |
7+
ModuleNodes$AliasKeywordNode
8+
attributes:
9+
flags = 1
10+
newName = :a
11+
oldName = :b
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
subject: "Alias"
2+
description: "alias global variables"
3+
focused_on_node: "org.truffleruby.language.globals.AliasGlobalVarNode"
4+
ruby: |
5+
alias $a $b
6+
ast: |
7+
AliasGlobalVarNode
8+
attributes:
9+
flags = 1
10+
newName = "$a"
11+
oldName = "$b"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
subject: "Alias"
2+
description: "alias keywords"
3+
focused_on_node: "org.truffleruby.core.module.ModuleNodes$AliasKeywordNode"
4+
ruby: |
5+
alias a b
6+
ast: |
7+
ModuleNodes$AliasKeywordNode
8+
attributes:
9+
flags = 1
10+
newName = :a
11+
oldName = :b
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
subject: "Alias"
2+
description: "alias Symbols"
3+
focused_on_node: "org.truffleruby.core.module.ModuleNodes$AliasKeywordNode"
4+
ruby: |
5+
alias :a :b
6+
ast: |
7+
ModuleNodes$AliasKeywordNode
8+
attributes:
9+
flags = 1
10+
newName = :a
11+
oldName = :b
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
subject: "AND keyword"
2+
description: "Control flow `and` operator"
3+
focused_on_node: "org.truffleruby.language.control.AndNode"
4+
ruby: |
5+
1 and 2
6+
ast: |
7+
AndNode
8+
attributes:
9+
flags = 1
10+
children:
11+
left =
12+
IntegerFixnumLiteralNode
13+
attributes:
14+
flags = 0
15+
value = 1
16+
right =
17+
IntegerFixnumLiteralNode
18+
attributes:
19+
flags = 0
20+
value = 2
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
subject: "Array"
2+
description: "Array literal"
3+
focused_on_node: "org.truffleruby.core.array.ArrayLiteralNode$UninitialisedArrayLiteralNode"
4+
ruby: |
5+
[1, true, nil]
6+
ast: |
7+
ArrayLiteralNode$UninitialisedArrayLiteralNode
8+
attributes:
9+
flags = 1
10+
language = org.truffleruby.RubyLanguage@...
11+
children:
12+
values = [
13+
IntegerFixnumLiteralNode
14+
attributes:
15+
flags = 0
16+
value = 1
17+
BooleanLiteralNode
18+
attributes:
19+
flags = 0
20+
value = true
21+
NilLiteralNode
22+
attributes:
23+
flags = 0
24+
isImplicit = false
25+
]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
subject: "Array"
2+
description: "Empty array literal"
3+
focused_on_node: "org.truffleruby.core.array.ArrayLiteralNode$UninitialisedArrayLiteralNode"
4+
ruby: |
5+
[]
6+
ast: |
7+
ArrayLiteralNode$UninitialisedArrayLiteralNode
8+
attributes:
9+
flags = 1
10+
language = org.truffleruby.RubyLanguage@...

0 commit comments

Comments
 (0)