Add test data for case-in expressions

This commit is contained in:
Arthur Baars
2021-11-24 17:04:40 +01:00
parent af4c3122ca
commit 16e1e97ff0
5 changed files with 638 additions and 9 deletions

View File

@@ -170,7 +170,7 @@ calls/calls.rb:
# 106| getStmt: [CaseExpr] case ...
# 106| getValue: [MethodCall] call to foo
# 106| getReceiver: [Self, SelfVariableAccess] self
# 107| getBranch: [WhenExpr] when ...
# 107| getBranch/getWhenBranch: [WhenExpr] when ...
# 107| getPattern: [MethodCall] call to bar
# 107| getReceiver: [Self, SelfVariableAccess] self
# 107| getBody: [StmtSequence] then ...
@@ -179,7 +179,7 @@ calls/calls.rb:
# 110| getStmt: [CaseExpr] case ...
# 110| getValue: [MethodCall] call to foo
# 110| getReceiver: [ConstantReadAccess] X
# 111| getBranch: [WhenExpr] when ...
# 111| getBranch/getWhenBranch: [WhenExpr] when ...
# 111| getPattern: [MethodCall] call to bar
# 111| getReceiver: [ConstantReadAccess] X
# 111| getBody: [StmtSequence] then ...
@@ -689,36 +689,408 @@ control/cases.rb:
# 5| getAnOperand/getRightOperand: [IntegerLiteral] 0
# 8| getStmt: [CaseExpr] case ...
# 8| getValue: [LocalVariableAccess] a
# 9| getBranch: [WhenExpr] when ...
# 9| getBranch/getWhenBranch: [WhenExpr] when ...
# 9| getPattern: [LocalVariableAccess] b
# 9| getBody: [StmtSequence] then ...
# 10| getStmt: [IntegerLiteral] 100
# 11| getBranch: [WhenExpr] when ...
# 11| getBranch/getWhenBranch: [WhenExpr] when ...
# 11| getPattern: [LocalVariableAccess] c
# 11| getPattern: [LocalVariableAccess] d
# 11| getBody: [StmtSequence] then ...
# 12| getStmt: [IntegerLiteral] 200
# 13| getBranch: [StmtSequence] else ...
# 13| getBranch/getElseBranch: [StmtSequence] else ...
# 14| getStmt: [IntegerLiteral] 300
# 18| getStmt: [CaseExpr] case ...
# 19| getBranch: [WhenExpr] when ...
# 19| getBranch/getWhenBranch: [WhenExpr] when ...
# 19| getPattern: [GTExpr] ... > ...
# 19| getAnOperand/getGreaterOperand/getLeftOperand/getReceiver: [LocalVariableAccess] a
# 19| getAnOperand/getArgument/getLesserOperand/getRightOperand: [LocalVariableAccess] b
# 19| getBody: [StmtSequence] then ...
# 19| getStmt: [IntegerLiteral] 10
# 20| getBranch: [WhenExpr] when ...
# 20| getBranch/getWhenBranch: [WhenExpr] when ...
# 20| getPattern: [EqExpr] ... == ...
# 20| getAnOperand/getLeftOperand/getReceiver: [LocalVariableAccess] a
# 20| getAnOperand/getArgument/getRightOperand: [LocalVariableAccess] b
# 20| getBody: [StmtSequence] then ...
# 20| getStmt: [IntegerLiteral] 20
# 21| getBranch: [WhenExpr] when ...
# 21| getBranch/getWhenBranch: [WhenExpr] when ...
# 21| getPattern: [LTExpr] ... < ...
# 21| getAnOperand/getLeftOperand/getLesserOperand/getReceiver: [LocalVariableAccess] a
# 21| getAnOperand/getArgument/getGreaterOperand/getRightOperand: [LocalVariableAccess] b
# 21| getBody: [StmtSequence] then ...
# 21| getStmt: [IntegerLiteral] 30
# 26| getStmt: [CaseMatch] case ... in
# 26| getValue: [MethodCall] call to expr
# 26| getReceiver: [Self, SelfVariableAccess] self
# 27| getBranch/getInClause: [InClause] in ... then ...
# 27| getPattern: [IntegerLiteral] 5
# 27| getBody: [StmtSequence] then ...
# 27| getStmt: [BooleanLiteral] true
# 28| getBranch/getElseBranch: [StmtSequence] else ...
# 28| getStmt: [BooleanLiteral] false
# 31| getStmt: [CaseMatch] case ... in
# 31| getValue: [MethodCall] call to expr
# 31| getReceiver: [Self, SelfVariableAccess] self
# 32| getBranch/getInClause: [InClause] in ... then ...
# 32| getPattern: [LocalVariableAccess] x
# 32| getGuard: [UnlessGuard] unless ...
# 32| getCondition: [LTExpr] ... < ...
# 32| getAnOperand/getLeftOperand/getLesserOperand/getReceiver: [LocalVariableAccess] x
# 32| getAnOperand/getArgument/getGreaterOperand/getRightOperand: [IntegerLiteral] 0
# 32| getBody: [StmtSequence] then ...
# 33| getStmt: [BooleanLiteral] true
# 34| getBranch/getInClause: [InClause] in ... then ...
# 34| getPattern: [LocalVariableAccess] x
# 34| getGuard: [IfGuard] if ...
# 34| getCondition: [LTExpr] ... < ...
# 34| getAnOperand/getLeftOperand/getLesserOperand/getReceiver: [LocalVariableAccess] x
# 34| getAnOperand/getArgument/getGreaterOperand/getRightOperand: [IntegerLiteral] 0
# 34| getBody: [StmtSequence] then ...
# 35| getStmt: [BooleanLiteral] true
# 36| getBranch/getElseBranch: [StmtSequence] else ...
# 36| getStmt: [BooleanLiteral] false
# 39| getStmt: [CaseMatch] case ... in
# 39| getValue: [MethodCall] call to expr
# 39| getReceiver: [Self, SelfVariableAccess] self
# 40| getBranch/getInClause: [InClause] in ... then ...
# 40| getPattern: [IntegerLiteral] 5
# 41| getBranch/getInClause: [InClause] in ... then ...
# 41| getPattern: [ArrayPattern] [ ..., * ]
# 41| getPrefixElement/getSuffixElement: [IntegerLiteral] 5
# 42| getBranch/getInClause: [InClause] in ... then ...
# 42| getPattern: [ArrayPattern] [ ..., * ]
# 42| getPrefixElement: [IntegerLiteral] 1
# 42| getPrefixElement: [IntegerLiteral] 2
# 43| getBranch/getInClause: [InClause] in ... then ...
# 43| getPattern: [ArrayPattern] [ ..., * ]
# 43| getPrefixElement/getSuffixElement: [IntegerLiteral] 1
# 43| getPrefixElement/getSuffixElement: [IntegerLiteral] 2
# 44| getBranch/getInClause: [InClause] in ... then ...
# 44| getPattern: [ArrayPattern] [ ..., * ]
# 44| getPrefixElement: [IntegerLiteral] 1
# 44| getPrefixElement: [IntegerLiteral] 2
# 44| getPrefixElement: [IntegerLiteral] 3
# 45| getBranch/getInClause: [InClause] in ... then ...
# 45| getPattern: [ArrayPattern] [ ..., * ]
# 45| getPrefixElement/getSuffixElement: [IntegerLiteral] 1
# 45| getPrefixElement/getSuffixElement: [IntegerLiteral] 2
# 45| getPrefixElement/getSuffixElement: [IntegerLiteral] 3
# 46| getBranch/getInClause: [InClause] in ... then ...
# 46| getPattern: [ArrayPattern] [ ..., * ]
# 46| getPrefixElement/getSuffixElement: [IntegerLiteral] 1
# 46| getPrefixElement/getSuffixElement: [IntegerLiteral] 2
# 46| getPrefixElement/getSuffixElement: [IntegerLiteral] 3
# 47| getBranch/getInClause: [InClause] in ... then ...
# 47| getPattern: [ArrayPattern] [ ..., * ]
# 47| getPrefixElement/getSuffixElement: [IntegerLiteral] 1
# 47| getRestVariable: [LocalVariableAccess] x
# 47| getSuffixElement: [IntegerLiteral] 3
# 48| getBranch/getInClause: [InClause] in ... then ...
# 48| getPattern: [ArrayPattern] [ ..., * ]
# 49| getBranch/getInClause: [InClause] in ... then ...
# 49| getPattern: [ArrayPattern] [ ..., * ]
# 49| getSuffixElement: [IntegerLiteral] 3
# 49| getSuffixElement: [IntegerLiteral] 4
# 50| getBranch/getInClause: [InClause] in ... then ...
# 50| getPattern: [FindPattern] [ *,...,* ]
# 50| getElement: [IntegerLiteral] 3
# 51| getBranch/getInClause: [InClause] in ... then ...
# 51| getPattern: [FindPattern] [ *,...,* ]
# 51| getPrefix: [LocalVariableAccess] a
# 51| getElement: [IntegerLiteral] 3
# 51| getSuffix: [LocalVariableAccess] b
# 52| getBranch/getInClause: [InClause] in ... then ...
# 52| getPattern: [HashPattern] { ..., ** }
# 52| getKey: [SymbolLiteral] :a
# 53| getBranch/getInClause: [InClause] in ... then ...
# 53| getPattern: [HashPattern] { ..., ** }
# 53| getKey: [SymbolLiteral] :a
# 53| getValue: [IntegerLiteral] 5
# 54| getBranch/getInClause: [InClause] in ... then ...
# 54| getPattern: [HashPattern] { ..., ** }
# 54| getKey: [SymbolLiteral] :a
# 54| getValue: [IntegerLiteral] 5
# 55| getBranch/getInClause: [InClause] in ... then ...
# 55| getPattern: [HashPattern] { ..., ** }
# 55| getKey: [SymbolLiteral] :a
# 55| getValue: [IntegerLiteral] 5
# 55| getKey: [SymbolLiteral] :b
# 56| getBranch/getInClause: [InClause] in ... then ...
# 56| getPattern: [HashPattern] { ..., ** }
# 56| getKey: [SymbolLiteral] :a
# 56| getValue: [IntegerLiteral] 5
# 56| getKey: [SymbolLiteral] :b
# 56| getRestVariable: [LocalVariableAccess] map
# 57| getBranch/getInClause: [InClause] in ... then ...
# 57| getPattern: [HashPattern] { ..., ** }
# 57| getKey: [SymbolLiteral] :a
# 57| getValue: [IntegerLiteral] 5
# 57| getKey: [SymbolLiteral] :b
# 58| getBranch/getInClause: [InClause] in ... then ...
# 58| getPattern: [HashPattern] { ..., ** }
# 59| getBranch/getInClause: [InClause] in ... then ...
# 59| getPattern: [ArrayPattern] [ ..., * ]
# 59| getPrefixElement: [IntegerLiteral] 5
# 60| getBranch/getInClause: [InClause] in ... then ...
# 60| getPattern: [ArrayPattern] [ ..., * ]
# 60| getPrefixElement/getSuffixElement: [IntegerLiteral] 5
# 61| getBranch/getInClause: [InClause] in ... then ...
# 61| getPattern: [ArrayPattern] [ ..., * ]
# 61| getPrefixElement: [IntegerLiteral] 1
# 61| getPrefixElement: [IntegerLiteral] 2
# 62| getBranch/getInClause: [InClause] in ... then ...
# 62| getPattern: [ArrayPattern] [ ..., * ]
# 62| getPrefixElement/getSuffixElement: [IntegerLiteral] 1
# 62| getPrefixElement/getSuffixElement: [IntegerLiteral] 2
# 63| getBranch/getInClause: [InClause] in ... then ...
# 63| getPattern: [ArrayPattern] [ ..., * ]
# 63| getPrefixElement: [IntegerLiteral] 1
# 63| getPrefixElement: [IntegerLiteral] 2
# 63| getPrefixElement: [IntegerLiteral] 3
# 64| getBranch/getInClause: [InClause] in ... then ...
# 64| getPattern: [ArrayPattern] [ ..., * ]
# 64| getPrefixElement/getSuffixElement: [IntegerLiteral] 1
# 64| getPrefixElement/getSuffixElement: [IntegerLiteral] 2
# 64| getPrefixElement/getSuffixElement: [IntegerLiteral] 3
# 65| getBranch/getInClause: [InClause] in ... then ...
# 65| getPattern: [ArrayPattern] [ ..., * ]
# 65| getPrefixElement/getSuffixElement: [IntegerLiteral] 1
# 65| getPrefixElement/getSuffixElement: [IntegerLiteral] 2
# 65| getPrefixElement/getSuffixElement: [IntegerLiteral] 3
# 66| getBranch/getInClause: [InClause] in ... then ...
# 66| getPattern: [ArrayPattern] [ ..., * ]
# 66| getPrefixElement/getSuffixElement: [IntegerLiteral] 1
# 66| getRestVariable: [LocalVariableAccess] x
# 66| getSuffixElement: [IntegerLiteral] 3
# 67| getBranch/getInClause: [InClause] in ... then ...
# 67| getPattern: [ArrayPattern] [ ..., * ]
# 68| getBranch/getInClause: [InClause] in ... then ...
# 68| getPattern: [ArrayPattern] [ ..., * ]
# 68| getSuffixElement: [IntegerLiteral] 3
# 68| getSuffixElement: [IntegerLiteral] 4
# 69| getBranch/getInClause: [InClause] in ... then ...
# 69| getPattern: [FindPattern] [ *,...,* ]
# 69| getElement: [IntegerLiteral] 3
# 70| getBranch/getInClause: [InClause] in ... then ...
# 70| getPattern: [FindPattern] [ *,...,* ]
# 70| getPrefix: [LocalVariableAccess] a
# 70| getElement: [IntegerLiteral] 3
# 70| getSuffix: [LocalVariableAccess] b
# 71| getBranch/getInClause: [InClause] in ... then ...
# 71| getPattern: [HashPattern] { ..., ** }
# 71| getKey: [SymbolLiteral] :a
# 72| getBranch/getInClause: [InClause] in ... then ...
# 72| getPattern: [HashPattern] { ..., ** }
# 72| getKey: [SymbolLiteral] :a
# 72| getValue: [IntegerLiteral] 5
# 73| getBranch/getInClause: [InClause] in ... then ...
# 73| getPattern: [HashPattern] { ..., ** }
# 73| getKey: [SymbolLiteral] :a
# 73| getValue: [IntegerLiteral] 5
# 74| getBranch/getInClause: [InClause] in ... then ...
# 74| getPattern: [HashPattern] { ..., ** }
# 74| getKey: [SymbolLiteral] :a
# 74| getValue: [IntegerLiteral] 5
# 74| getKey: [SymbolLiteral] :b
# 75| getBranch/getInClause: [InClause] in ... then ...
# 75| getPattern: [HashPattern] { ..., ** }
# 75| getKey: [SymbolLiteral] :a
# 75| getValue: [IntegerLiteral] 5
# 75| getKey: [SymbolLiteral] :b
# 75| getRestVariable: [LocalVariableAccess] map
# 76| getBranch/getInClause: [InClause] in ... then ...
# 76| getPattern: [HashPattern] { ..., ** }
# 76| getKey: [SymbolLiteral] :a
# 76| getValue: [IntegerLiteral] 5
# 76| getKey: [SymbolLiteral] :b
# 77| getBranch/getInClause: [InClause] in ... then ...
# 77| getPattern: [HashPattern] { ..., ** }
# 78| getBranch/getInClause: [InClause] in ... then ...
# 78| getPattern: [HashPattern] { ..., ** }
# 79| getBranch/getInClause: [InClause] in ... then ...
# 79| getPattern: [ArrayPattern] [ ..., * ]
# 84| getStmt: [AssignExpr] ... = ...
# 84| getAnOperand/getLeftOperand: [LocalVariableAccess] foo
# 84| getAnOperand/getRightOperand: [IntegerLiteral] 42
# 86| getStmt: [CaseMatch] case ... in
# 86| getValue: [MethodCall] call to expr
# 86| getReceiver: [Self, SelfVariableAccess] self
# 87| getBranch/getInClause: [InClause] in ... then ...
# 87| getPattern: [IntegerLiteral] 5
# 88| getBranch/getInClause: [InClause] in ... then ...
# 88| getPattern: [VariableReferencePattern] ^...
# 88| getVariableAccess: [LocalVariableAccess] foo
# 89| getBranch/getInClause: [InClause] in ... then ...
# 89| getPattern: [LocalVariableAccess] var
# 90| getBranch/getInClause: [InClause] in ... then ...
# 90| getPattern: [StringLiteral] "string"
# 90| getComponent: [StringTextComponent] string
# 91| getBranch/getInClause: [InClause] in ... then ...
# 91| getPattern: [ArrayLiteral] %w(...)
# 91| getElement: [StringLiteral] "foo"
# 91| getComponent: [StringTextComponent] foo
# 91| getElement: [StringLiteral] "bar"
# 91| getComponent: [StringTextComponent] bar
# 92| getBranch/getInClause: [InClause] in ... then ...
# 92| getPattern: [ArrayLiteral] %i(...)
# 92| getElement: [SymbolLiteral] :"foo"
# 92| getComponent: [StringTextComponent] foo
# 92| getElement: [SymbolLiteral] :"bar"
# 92| getComponent: [StringTextComponent] bar
# 93| getBranch/getInClause: [InClause] in ... then ...
# 93| getPattern: [RegExpLiteral] /.*abc[0-9]/
# 93| getParsed: [RegExpSequence] .*abc[0-9]
# 93| 0: [RegExpStar] .*
# 93| 0: [RegExpDot] .
# 93| 1: [RegExpConstant, RegExpNormalChar] a
# 93| 2: [RegExpConstant, RegExpNormalChar] b
# 93| 3: [RegExpConstant, RegExpNormalChar] c
# 93| 4: [RegExpCharacterClass] [0-9]
# 93| 0: [RegExpCharacterRange] 0-9
# 93| 0: [RegExpConstant, RegExpNormalChar] 0
# 93| 1: [RegExpConstant, RegExpNormalChar] 9
# 93| getComponent: [StringTextComponent] .*abc[0-9]
# 94| getBranch/getInClause: [InClause] in ... then ...
# 94| getPattern: [RangeLiteral] _ .. _
# 94| getBegin: [IntegerLiteral] 5
# 94| getEnd: [IntegerLiteral] 10
# 95| getBranch/getInClause: [InClause] in ... then ...
# 95| getPattern: [RangeLiteral] _ .. _
# 95| getEnd: [IntegerLiteral] 10
# 96| getBranch/getInClause: [InClause] in ... then ...
# 96| getPattern: [RangeLiteral] _ .. _
# 96| getBegin: [IntegerLiteral] 5
# 97| getBranch/getInClause: [InClause] in ... then ...
# 97| getPattern: [AsPattern] ... => ...
# 97| getValue: [IntegerLiteral] 5
# 97| getVariableAccess: [LocalVariableAccess] x
# 98| getBranch/getInClause: [InClause] in ... then ...
# 98| getPattern: [AlternativePattern] ... | ...
# 98| getAlternative: [IntegerLiteral] 5
# 98| getAlternative: [VariableReferencePattern] ^...
# 98| getVariableAccess: [LocalVariableAccess] foo
# 98| getAlternative: [LocalVariableAccess] var
# 98| getAlternative: [StringLiteral] "string"
# 98| getComponent: [StringTextComponent] string
# 99| getBranch/getInClause: [InClause] in ... then ...
# 99| getPattern: [ConstantReadAccess] Foo
# 100| getBranch/getInClause: [InClause] in ... then ...
# 100| getPattern: [ConstantReadAccess] Bar
# 100| getScopeExpr: [ConstantReadAccess] Foo
# 101| getBranch/getInClause: [InClause] in ... then ...
# 101| getPattern: [ConstantReadAccess] Bar
# 101| getScopeExpr: [ConstantReadAccess] Foo
# 102| getBranch/getInClause: [InClause] in ... then ...
# 102| getPattern: [AlternativePattern] ... | ...
# 102| getAlternative: [NilLiteral] nil
# 102| getAlternative: [Self, SelfVariableAccess] self
# 102| getAlternative: [BooleanLiteral] true
# 102| getAlternative: [BooleanLiteral] false
# 102| getAlternative: [LineLiteral] __LINE__
# 102| getAlternative: [FileLiteral] __FILE__
# 102| getAlternative: [EncodingLiteral] __ENCODING__
# 103| getBranch/getInClause: [InClause] in ... then ...
# 103| getPattern: [Lambda] -> { ... }
# 103| getParameter: [SimpleParameter] x
# 103| getDefiningAccess: [LocalVariableAccess] x
# 103| getStmt: [EqExpr] ... == ...
# 103| getAnOperand/getLeftOperand/getReceiver: [LocalVariableAccess] x
# 103| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 10
# 104| getBranch/getInClause: [InClause] in ... then ...
# 104| getPattern: [SymbolLiteral] :foo
# 105| getBranch/getInClause: [InClause] in ... then ...
# 105| getPattern: [SymbolLiteral] :"foo bar"
# 105| getComponent: [StringTextComponent] foo bar
# 106| getBranch/getInClause: [InClause] in ... then ...
# 106| getPattern: [AlternativePattern] ... | ...
# 106| getAlternative: [UnaryMinusExpr] - ...
# 106| getAnOperand/getOperand/getReceiver: [IntegerLiteral] 5
# 106| getAlternative: [UnaryPlusExpr] + ...
# 106| getAnOperand/getOperand/getReceiver: [IntegerLiteral] 10
# 111| getStmt: [CaseMatch] case ... in
# 111| getValue: [MethodCall] call to expr
# 111| getReceiver: [Self, SelfVariableAccess] self
# 112| getBranch/getInClause: [InClause] in ... then ...
# 112| getPattern: [ArrayPattern] [ ..., * ]
# 113| getBranch/getInClause: [InClause] in ... then ...
# 113| getPattern: [ArrayPattern] [ ..., * ]
# 113| getPrefixElement: [LocalVariableAccess] x
# 114| getBranch/getInClause: [InClause] in ... then ...
# 114| getPattern: [ArrayPattern] [ ..., * ]
# 114| getPrefixElement/getSuffixElement: [LocalVariableAccess] x
# 115| getBranch/getInClause: [InClause] in ... then ...
# 115| getPattern: [ArrayPattern] [ ..., * ]
# 115| getClass: [ConstantReadAccess] Bar
# 115| getScopeExpr: [ConstantReadAccess] Foo
# 116| getBranch/getInClause: [InClause] in ... then ...
# 116| getPattern: [ArrayPattern] [ ..., * ]
# 116| getClass: [ConstantReadAccess] Foo
# 117| getBranch/getInClause: [InClause] in ... then ...
# 117| getPattern: [ArrayPattern] [ ..., * ]
# 117| getClass: [ConstantReadAccess] Bar
# 118| getBranch/getInClause: [InClause] in ... then ...
# 118| getPattern: [ArrayPattern] [ ..., * ]
# 118| getClass: [ConstantReadAccess] Bar
# 118| getPrefixElement/getSuffixElement: [LocalVariableAccess] a
# 118| getPrefixElement/getSuffixElement: [LocalVariableAccess] b
# 118| getRestVariable: [LocalVariableAccess] c
# 118| getSuffixElement: [LocalVariableAccess] d
# 118| getSuffixElement: [LocalVariableAccess] e
# 123| getStmt: [CaseMatch] case ... in
# 123| getValue: [MethodCall] call to expr
# 123| getReceiver: [Self, SelfVariableAccess] self
# 124| getBranch/getInClause: [InClause] in ... then ...
# 124| getPattern: [FindPattern] [ *,...,* ]
# 124| getElement: [LocalVariableAccess] x
# 125| getBranch/getInClause: [InClause] in ... then ...
# 125| getPattern: [FindPattern] [ *,...,* ]
# 125| getPrefix: [LocalVariableAccess] x
# 125| getElement: [IntegerLiteral] 1
# 125| getElement: [IntegerLiteral] 2
# 125| getSuffix: [LocalVariableAccess] y
# 126| getBranch/getInClause: [InClause] in ... then ...
# 126| getPattern: [FindPattern] [ *,...,* ]
# 126| getClass: [ConstantReadAccess] Bar
# 126| getScopeExpr: [ConstantReadAccess] Foo
# 126| getElement: [IntegerLiteral] 1
# 127| getBranch/getInClause: [InClause] in ... then ...
# 127| getPattern: [FindPattern] [ *,...,* ]
# 127| getClass: [ConstantReadAccess] Foo
# 127| getElement: [ConstantReadAccess] Bar
# 132| getStmt: [CaseMatch] case ... in
# 132| getValue: [MethodCall] call to expr
# 132| getReceiver: [Self, SelfVariableAccess] self
# 133| getBranch/getInClause: [InClause] in ... then ...
# 133| getPattern: [HashPattern] { ..., ** }
# 134| getBranch/getInClause: [InClause] in ... then ...
# 134| getPattern: [HashPattern] { ..., ** }
# 134| getKey: [SymbolLiteral] :x
# 135| getBranch/getInClause: [InClause] in ... then ...
# 135| getPattern: [HashPattern] { ..., ** }
# 135| getClass: [ConstantReadAccess] Bar
# 135| getScopeExpr: [ConstantReadAccess] Foo
# 135| getKey: [SymbolLiteral] :x
# 135| getValue: [IntegerLiteral] 1
# 136| getBranch/getInClause: [InClause] in ... then ...
# 136| getPattern: [HashPattern] { ..., ** }
# 136| getClass: [ConstantReadAccess] Bar
# 136| getScopeExpr: [ConstantReadAccess] Foo
# 136| getKey: [SymbolLiteral] :x
# 136| getValue: [IntegerLiteral] 1
# 136| getKey: [SymbolLiteral] :a
# 136| getRestVariable: [LocalVariableAccess] rest
# 137| getBranch/getInClause: [InClause] in ... then ...
# 137| getPattern: [HashPattern] { ..., ** }
# 137| getClass: [ConstantReadAccess] Foo
# 137| getKey: [SymbolLiteral] :y
# 138| getBranch/getInClause: [InClause] in ... then ...
# 138| getPattern: [HashPattern] { ..., ** }
# 138| getClass: [ConstantReadAccess] Bar
# 139| getBranch/getInClause: [InClause] in ... then ...
# 139| getPattern: [HashPattern] { ..., ** }
# 139| getClass: [ConstantReadAccess] Bar
# 139| getKey: [SymbolLiteral] :a
# 139| getValue: [IntegerLiteral] 1
modules/classes.rb:
# 2| [Toplevel] classes.rb
# 3| getStmt: [ClassDeclaration] Foo

View File

@@ -266,6 +266,21 @@ calls/calls.rb:
# 340| getArgument: [IntegerLiteral] 4
# 340| getArgument: [IntegerLiteral] 5
# 340| getArgument: [IntegerLiteral] 6
control/cases.rb:
# 91| [ArrayLiteral] %w(...)
# 91| getDesugared: [MethodCall] call to []
# 91| getReceiver: [ConstantReadAccess] Array
# 91| getArgument: [StringLiteral] "foo"
# 91| getComponent: [StringTextComponent] foo
# 91| getArgument: [StringLiteral] "bar"
# 91| getComponent: [StringTextComponent] bar
# 92| [ArrayLiteral] %i(...)
# 92| getDesugared: [MethodCall] call to []
# 92| getReceiver: [ConstantReadAccess] Array
# 92| getArgument: [SymbolLiteral] :"foo"
# 92| getComponent: [StringTextComponent] foo
# 92| getArgument: [SymbolLiteral] :"bar"
# 92| getComponent: [StringTextComponent] bar
constants/constants.rb:
# 20| [ArrayLiteral] [...]
# 20| getDesugared: [MethodCall] call to []

View File

@@ -96,6 +96,122 @@
| control/cases.rb:21:6:21:6 | a | 0 |
| control/cases.rb:21:10:21:10 | b | 0 |
| control/cases.rb:21:18:21:19 | 30 | 30 |
| control/cases.rb:27:6:27:6 | 5 | 5 |
| control/cases.rb:27:13:27:16 | true | true |
| control/cases.rb:28:8:28:12 | false | false |
| control/cases.rb:32:19:32:19 | 0 | 0 |
| control/cases.rb:33:8:33:11 | true | true |
| control/cases.rb:34:15:34:15 | 0 | 0 |
| control/cases.rb:35:8:35:11 | true | true |
| control/cases.rb:36:8:36:12 | false | false |
| control/cases.rb:40:6:40:6 | 5 | 5 |
| control/cases.rb:41:6:41:6 | 5 | 5 |
| control/cases.rb:42:6:42:6 | 1 | 1 |
| control/cases.rb:42:9:42:9 | 2 | 2 |
| control/cases.rb:43:6:43:6 | 1 | 1 |
| control/cases.rb:43:9:43:9 | 2 | 2 |
| control/cases.rb:44:6:44:6 | 1 | 1 |
| control/cases.rb:44:9:44:9 | 2 | 2 |
| control/cases.rb:44:12:44:12 | 3 | 3 |
| control/cases.rb:45:6:45:6 | 1 | 1 |
| control/cases.rb:45:9:45:9 | 2 | 2 |
| control/cases.rb:45:12:45:12 | 3 | 3 |
| control/cases.rb:46:6:46:6 | 1 | 1 |
| control/cases.rb:46:9:46:9 | 2 | 2 |
| control/cases.rb:46:12:46:12 | 3 | 3 |
| control/cases.rb:47:6:47:6 | 1 | 1 |
| control/cases.rb:47:13:47:13 | 3 | 3 |
| control/cases.rb:49:9:49:9 | 3 | 3 |
| control/cases.rb:49:12:49:12 | 4 | 4 |
| control/cases.rb:50:9:50:9 | 3 | 3 |
| control/cases.rb:51:10:51:10 | 3 | 3 |
| control/cases.rb:52:6:52:6 | :a | a |
| control/cases.rb:53:6:53:6 | :a | a |
| control/cases.rb:53:9:53:9 | 5 | 5 |
| control/cases.rb:54:6:54:6 | :a | a |
| control/cases.rb:54:9:54:9 | 5 | 5 |
| control/cases.rb:55:6:55:6 | :a | a |
| control/cases.rb:55:9:55:9 | 5 | 5 |
| control/cases.rb:55:12:55:12 | :b | b |
| control/cases.rb:56:6:56:6 | :a | a |
| control/cases.rb:56:9:56:9 | 5 | 5 |
| control/cases.rb:56:12:56:12 | :b | b |
| control/cases.rb:57:6:57:6 | :a | a |
| control/cases.rb:57:9:57:9 | 5 | 5 |
| control/cases.rb:57:12:57:12 | :b | b |
| control/cases.rb:59:7:59:7 | 5 | 5 |
| control/cases.rb:60:7:60:7 | 5 | 5 |
| control/cases.rb:61:7:61:7 | 1 | 1 |
| control/cases.rb:61:10:61:10 | 2 | 2 |
| control/cases.rb:62:7:62:7 | 1 | 1 |
| control/cases.rb:62:10:62:10 | 2 | 2 |
| control/cases.rb:63:7:63:7 | 1 | 1 |
| control/cases.rb:63:10:63:10 | 2 | 2 |
| control/cases.rb:63:13:63:13 | 3 | 3 |
| control/cases.rb:64:7:64:7 | 1 | 1 |
| control/cases.rb:64:10:64:10 | 2 | 2 |
| control/cases.rb:64:13:64:13 | 3 | 3 |
| control/cases.rb:65:7:65:7 | 1 | 1 |
| control/cases.rb:65:10:65:10 | 2 | 2 |
| control/cases.rb:65:13:65:13 | 3 | 3 |
| control/cases.rb:66:7:66:7 | 1 | 1 |
| control/cases.rb:66:14:66:14 | 3 | 3 |
| control/cases.rb:68:10:68:10 | 3 | 3 |
| control/cases.rb:68:13:68:13 | 4 | 4 |
| control/cases.rb:69:10:69:10 | 3 | 3 |
| control/cases.rb:70:11:70:11 | 3 | 3 |
| control/cases.rb:71:7:71:7 | :a | a |
| control/cases.rb:72:7:72:7 | :a | a |
| control/cases.rb:72:10:72:10 | 5 | 5 |
| control/cases.rb:73:7:73:7 | :a | a |
| control/cases.rb:73:10:73:10 | 5 | 5 |
| control/cases.rb:74:7:74:7 | :a | a |
| control/cases.rb:74:10:74:10 | 5 | 5 |
| control/cases.rb:74:13:74:13 | :b | b |
| control/cases.rb:75:7:75:7 | :a | a |
| control/cases.rb:75:10:75:10 | 5 | 5 |
| control/cases.rb:75:13:75:13 | :b | b |
| control/cases.rb:76:7:76:7 | :a | a |
| control/cases.rb:76:10:76:10 | 5 | 5 |
| control/cases.rb:76:13:76:13 | :b | b |
| control/cases.rb:84:7:84:8 | 42 | 42 |
| control/cases.rb:87:6:87:6 | 5 | 5 |
| control/cases.rb:90:6:90:13 | "string" | string |
| control/cases.rb:91:9:91:11 | "foo" | foo |
| control/cases.rb:91:13:91:15 | "bar" | bar |
| control/cases.rb:92:9:92:11 | :"foo" | foo |
| control/cases.rb:92:13:92:15 | :"bar" | bar |
| control/cases.rb:93:6:93:17 | /.*abc[0-9]/ | .*abc[0-9] |
| control/cases.rb:94:6:94:6 | 5 | 5 |
| control/cases.rb:94:11:94:12 | 10 | 10 |
| control/cases.rb:95:9:95:10 | 10 | 10 |
| control/cases.rb:96:6:96:6 | 5 | 5 |
| control/cases.rb:97:6:97:6 | 5 | 5 |
| control/cases.rb:98:6:98:6 | 5 | 5 |
| control/cases.rb:98:23:98:30 | "string" | string |
| control/cases.rb:102:6:102:8 | nil | nil |
| control/cases.rb:102:19:102:22 | true | true |
| control/cases.rb:102:26:102:30 | false | false |
| control/cases.rb:102:34:102:41 | __LINE__ | 102 |
| control/cases.rb:102:45:102:52 | __FILE__ | control/cases.rb |
| control/cases.rb:102:56:102:67 | __ENCODING__ | UTF-8 |
| control/cases.rb:103:18:103:19 | 10 | 10 |
| control/cases.rb:104:6:104:9 | :foo | foo |
| control/cases.rb:105:6:105:15 | :"foo bar" | foo bar |
| control/cases.rb:106:7:106:7 | 5 | 5 |
| control/cases.rb:106:12:106:13 | 10 | 10 |
| control/cases.rb:125:11:125:11 | 1 | 1 |
| control/cases.rb:125:14:125:14 | 2 | 2 |
| control/cases.rb:126:18:126:18 | 1 | 1 |
| control/cases.rb:134:7:134:7 | :x | x |
| control/cases.rb:135:16:135:16 | :x | x |
| control/cases.rb:135:18:135:18 | 1 | 1 |
| control/cases.rb:136:16:136:16 | :x | x |
| control/cases.rb:136:18:136:18 | 1 | 1 |
| control/cases.rb:136:21:136:21 | :a | a |
| control/cases.rb:137:11:137:11 | :y | y |
| control/cases.rb:139:11:139:11 | :a | a |
| control/cases.rb:139:14:139:14 | 1 | 1 |
| control/conditionals.rb:2:5:2:5 | 0 | 0 |
| control/conditionals.rb:3:5:3:5 | 0 | 0 |
| control/conditionals.rb:4:5:4:5 | 0 | 0 |

View File

@@ -1,5 +1,12 @@
| cases.rb:8:1:15:3 | case ... | CaseExpr |
| cases.rb:18:1:22:3 | case ... | CaseExpr |
| cases.rb:26:1:29:3 | case ... in | CaseMatch |
| cases.rb:31:1:37:3 | case ... in | CaseMatch |
| cases.rb:39:1:80:3 | case ... in | CaseMatch |
| cases.rb:86:1:107:3 | case ... in | CaseMatch |
| cases.rb:111:1:119:3 | case ... in | CaseMatch |
| cases.rb:123:1:128:3 | case ... in | CaseMatch |
| cases.rb:132:1:140:3 | case ... in | CaseMatch |
| conditionals.rb:10:1:12:3 | if ... | IfExpr |
| conditionals.rb:15:1:19:3 | if ... | IfExpr |
| conditionals.rb:22:1:30:3 | if ... | IfExpr |

View File

@@ -19,4 +19,123 @@ case
when a > b then 10
when a == b then 20
when a < b then 30
end
end
# pattern matching
case expr
in 5 then true
else false
end
case expr
in x unless x < 0
then true
in x if x < 0
then true
else false
end
case expr
in 5
in 5,
in 1, 2
in 1, 2,
in 1, 2, 3
in 1, 2, 3,
in 1, 2, 3, *
in 1, *x, 3
in *
in *, 3, 4
in *, 3, *
in *a, 3, *b
in a:
in a: 5
in a: 5,
in a: 5, b:, **
in a: 5, b:, **map
in a: 5, b:, **nil
in **nil
in [5]
in [5,]
in [1, 2]
in [1, 2,]
in [1, 2, 3]
in [1, 2, 3,]
in [1, 2, 3, *]
in [1, *x, 3]
in [*]
in [*, 3, 4]
in [*, 3, *]
in [*a, 3, *b]
in {a:}
in {a: 5}
in {a: 5,}
in {a: 5, b:, **}
in {a: 5, b:, **map}
in {a: 5, b:, **nil}
in {**nil}
in {}
in []
end
# more pattern matching
foo = 42
case expr
in 5
in ^foo
in var
in "string"
in %w(foo bar)
in %i(foo bar)
in /.*abc[0-9]/
in 5 .. 10
in .. 10
in 5 ..
in 5 => x
in 5 | ^foo | var | "string"
in Foo
in Foo::Bar
in ::Foo::Bar
in nil | self | true | false | __LINE__ | __FILE__ | __ENCODING__
in -> x { x == 10 }
in :foo
in :"foo bar"
in -5 | +10
end
# array patterns
case expr
in [];
in [x];
in [x, ];
in Foo::Bar[];
in Foo();
in Bar(*);
in Bar(a, b, *c, d, e);
end
# find patterns
case expr
in [*, x, *];
in [*x, 1, 2, *y];
in Foo::Bar[*, 1, *];
in Foo(*, Bar, *);
end
# hash patterns
case expr
in {};
in {x:};
in Foo::Bar[ x:1 ];
in Foo::Bar[ x:1, a:, **rest ];
in Foo( y:);
in Bar( ** );
in Bar( a: 1, **nil);
end