Skip to content

Commit 78d3f39

Browse files
committed
Add YARP fixtures to test that String literal in when clause becomes frozen
1 parent b48056e commit 78d3f39

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
subject: "case expression"
2+
description: "with expression to match / and String literal in when clause (case exp when 'string' ... end)"
3+
notes: >
4+
String becomes frozen and is represented as FrozenStringLiteralNode
5+
focused_on_node: "org.truffleruby.language.control.IfElseNode"
6+
ruby: |
7+
case 42
8+
when "foo"
9+
true
10+
end
11+
ast: |
12+
IfElseNodeGen
13+
attributes:
14+
flags = 0
15+
sourceCharIndex = -1
16+
sourceLength = 0
17+
children:
18+
condition =
19+
InlinedCaseEqualNodeGen
20+
attributes:
21+
assumptions = [Assumption(valid, name=set_trace_func is not used)]
22+
flags = 0
23+
integerCaseEqualAssumption = Assumption(valid, name=inlined Integer#===)
24+
parameters = RubyCallNodeParameters{methodName='===', descriptor=NoKeywordArgumentsDescriptor, isSplatted=false, ignoreVisibility=true, isVCall=false, isSafeNavigation=false, isAttrAssign=false}
25+
sourceCharIndex = -1
26+
sourceLength = 0
27+
children:
28+
leftNode_ =
29+
FrozenStringLiteralNode
30+
attributes:
31+
definition = expression
32+
flags = 0
33+
frozenString = foo
34+
sourceCharIndex = 13
35+
sourceLength = 5
36+
rightNode_ =
37+
ReadLocalVariableNode
38+
attributes:
39+
flags = 0
40+
frameSlot = 2 # %case_0
41+
sourceCharIndex = -1
42+
sourceLength = 0
43+
type = FRAME_LOCAL
44+
elseBody =
45+
NilLiteralNode
46+
attributes:
47+
flags = 0
48+
sourceCharIndex = -1
49+
sourceLength = 0
50+
thenBody =
51+
BooleanLiteralNode
52+
attributes:
53+
flags = 1
54+
sourceCharIndex = 21
55+
sourceLength = 4
56+
value = true
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
subject: "case expression"
2+
description: "without expression to match / and String literal in when clause (case exp when 'string' ... end)"
3+
notes: >
4+
String becomes frozen and is represented as FrozenStringLiteralNode
5+
focused_on_node: "org.truffleruby.language.control.IfElseNode"
6+
ruby: |
7+
case
8+
when "foo"
9+
true
10+
end
11+
ast: |
12+
IfElseNodeGen
13+
attributes:
14+
flags = 1
15+
sourceCharIndex = 0
16+
sourceLength = 26
17+
children:
18+
condition =
19+
FrozenStringLiteralNode
20+
attributes:
21+
definition = expression
22+
flags = 0
23+
frozenString = foo
24+
sourceCharIndex = 10
25+
sourceLength = 5
26+
elseBody =
27+
NilLiteralNode
28+
attributes:
29+
flags = 0
30+
sourceCharIndex = -1
31+
sourceLength = 0
32+
thenBody =
33+
BooleanLiteralNode
34+
attributes:
35+
flags = 1
36+
sourceCharIndex = 18
37+
sourceLength = 4
38+
value = true

0 commit comments

Comments
 (0)