Skip to content

Commit 64a122a

Browse files
makenowjustmatzbot
authored andcommitted
[ruby/prism] Add test cases for in in case condition
Fix ruby/prism#1515 It is also fixed by ruby#1807, so this adds only test cases. ruby/prism@a0092f075e
1 parent 9786b90 commit 64a122a

File tree

2 files changed

+107
-13
lines changed

2 files changed

+107
-13
lines changed

test/prism/fixtures/case.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,15 @@ case type;
3030
end
3131

3232
case ;;;;;;;; when 1; end
33+
34+
case 1 in 2
35+
when 3
36+
end
37+
38+
case 1 in 2; when 3; end
39+
40+
case 1 in 2
41+
in 3
42+
end
43+
44+
case 1 in 2; in 3; end

test/prism/snapshots/case.txt

Lines changed: 95 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
@ ProgramNode (location: (1,0)-(32,25))
1+
@ ProgramNode (location: (1,0)-(44,22))
22
├── locals: []
33
└── statements:
4-
@ StatementsNode (location: (1,0)-(32,25))
5-
└── body: (length: 9)
4+
@ StatementsNode (location: (1,0)-(44,22))
5+
└── body: (length: 13)
66
├── @ CaseNode (location: (1,0)-(3,3))
77
│ ├── predicate:
88
│ │ @ SymbolNode (location: (1,5)-(1,8))
@@ -254,15 +254,97 @@
254254
│ │ └── end_keyword_loc: (30,3)-(30,6) = "end"
255255
│ ├── case_keyword_loc: (27,0)-(27,4) = "case"
256256
│ └── end_keyword_loc: (30,3)-(30,6) = "end"
257-
└── @ CaseNode (location: (32,0)-(32,25))
258-
├── predicate: ∅
257+
├── @ CaseNode (location: (32,0)-(32,25))
258+
│ ├── predicate: ∅
259+
│ ├── conditions: (length: 1)
260+
│ │ └── @ WhenNode (location: (32,14)-(32,20))
261+
│ │ ├── keyword_loc: (32,14)-(32,18) = "when"
262+
│ │ ├── conditions: (length: 1)
263+
│ │ │ └── @ IntegerNode (location: (32,19)-(32,20))
264+
│ │ │ └── flags: decimal
265+
│ │ └── statements: ∅
266+
│ ├── consequent: ∅
267+
│ ├── case_keyword_loc: (32,0)-(32,4) = "case"
268+
│ └── end_keyword_loc: (32,22)-(32,25) = "end"
269+
├── @ CaseNode (location: (34,0)-(36,3))
270+
│ ├── predicate:
271+
│ │ @ MatchPredicateNode (location: (34,5)-(34,11))
272+
│ │ ├── value:
273+
│ │ │ @ IntegerNode (location: (34,5)-(34,6))
274+
│ │ │ └── flags: decimal
275+
│ │ ├── pattern:
276+
│ │ │ @ IntegerNode (location: (34,10)-(34,11))
277+
│ │ │ └── flags: decimal
278+
│ │ └── operator_loc: (34,7)-(34,9) = "in"
279+
│ ├── conditions: (length: 1)
280+
│ │ └── @ WhenNode (location: (35,0)-(35,6))
281+
│ │ ├── keyword_loc: (35,0)-(35,4) = "when"
282+
│ │ ├── conditions: (length: 1)
283+
│ │ │ └── @ IntegerNode (location: (35,5)-(35,6))
284+
│ │ │ └── flags: decimal
285+
│ │ └── statements: ∅
286+
│ ├── consequent: ∅
287+
│ ├── case_keyword_loc: (34,0)-(34,4) = "case"
288+
│ └── end_keyword_loc: (36,0)-(36,3) = "end"
289+
├── @ CaseNode (location: (38,0)-(38,24))
290+
│ ├── predicate:
291+
│ │ @ MatchPredicateNode (location: (38,5)-(38,11))
292+
│ │ ├── value:
293+
│ │ │ @ IntegerNode (location: (38,5)-(38,6))
294+
│ │ │ └── flags: decimal
295+
│ │ ├── pattern:
296+
│ │ │ @ IntegerNode (location: (38,10)-(38,11))
297+
│ │ │ └── flags: decimal
298+
│ │ └── operator_loc: (38,7)-(38,9) = "in"
299+
│ ├── conditions: (length: 1)
300+
│ │ └── @ WhenNode (location: (38,13)-(38,19))
301+
│ │ ├── keyword_loc: (38,13)-(38,17) = "when"
302+
│ │ ├── conditions: (length: 1)
303+
│ │ │ └── @ IntegerNode (location: (38,18)-(38,19))
304+
│ │ │ └── flags: decimal
305+
│ │ └── statements: ∅
306+
│ ├── consequent: ∅
307+
│ ├── case_keyword_loc: (38,0)-(38,4) = "case"
308+
│ └── end_keyword_loc: (38,21)-(38,24) = "end"
309+
├── @ CaseNode (location: (40,0)-(42,3))
310+
│ ├── predicate:
311+
│ │ @ MatchPredicateNode (location: (40,5)-(40,11))
312+
│ │ ├── value:
313+
│ │ │ @ IntegerNode (location: (40,5)-(40,6))
314+
│ │ │ └── flags: decimal
315+
│ │ ├── pattern:
316+
│ │ │ @ IntegerNode (location: (40,10)-(40,11))
317+
│ │ │ └── flags: decimal
318+
│ │ └── operator_loc: (40,7)-(40,9) = "in"
319+
│ ├── conditions: (length: 1)
320+
│ │ └── @ InNode (location: (41,0)-(41,4))
321+
│ │ ├── pattern:
322+
│ │ │ @ IntegerNode (location: (41,3)-(41,4))
323+
│ │ │ └── flags: decimal
324+
│ │ ├── statements: ∅
325+
│ │ ├── in_loc: (41,0)-(41,2) = "in"
326+
│ │ └── then_loc: ∅
327+
│ ├── consequent: ∅
328+
│ ├── case_keyword_loc: (40,0)-(40,4) = "case"
329+
│ └── end_keyword_loc: (42,0)-(42,3) = "end"
330+
└── @ CaseNode (location: (44,0)-(44,22))
331+
├── predicate:
332+
│ @ MatchPredicateNode (location: (44,5)-(44,11))
333+
│ ├── value:
334+
│ │ @ IntegerNode (location: (44,5)-(44,6))
335+
│ │ └── flags: decimal
336+
│ ├── pattern:
337+
│ │ @ IntegerNode (location: (44,10)-(44,11))
338+
│ │ └── flags: decimal
339+
│ └── operator_loc: (44,7)-(44,9) = "in"
259340
├── conditions: (length: 1)
260-
│ └── @ WhenNode (location: (32,14)-(32,20))
261-
│ ├── keyword_loc: (32,14)-(32,18) = "when"
262-
│ ├── conditions: (length: 1)
263-
│ │ └── @ IntegerNode (location: (32,19)-(32,20))
264-
│ │ └── flags: decimal
265-
│ └── statements: ∅
341+
│ └── @ InNode (location: (44,13)-(44,17))
342+
│ ├── pattern:
343+
│ │ @ IntegerNode (location: (44,16)-(44,17))
344+
│ │ └── flags: decimal
345+
│ ├── statements: ∅
346+
│ ├── in_loc: (44,13)-(44,15) = "in"
347+
│ └── then_loc: ∅
266348
├── consequent: ∅
267-
├── case_keyword_loc: (32,0)-(32,4) = "case"
268-
└── end_keyword_loc: (32,22)-(32,25) = "end"
349+
├── case_keyword_loc: (44,0)-(44,4) = "case"
350+
└── end_keyword_loc: (44,19)-(44,22) = "end"

0 commit comments

Comments
 (0)