Get rid of exprstatement! macro

For shorter exst! one
This commit is contained in:
greg 2018-11-05 19:58:55 -08:00
parent 1e9aa91c5d
commit eec315dd58

View File

@ -1121,17 +1121,6 @@ mod parse_tests {
macro_rules! val {
($var:expr) => { Value(Rc::new($var.to_string())) }
}
macro_rules! exprstatement {
($expr_type:expr) => { Statement::ExpressionStatement(Expression($expr_type, None)) };
($expr_type:expr, $type_anno:expr) => { Statement::ExpressionStatement(Expression($expr_type, Some($type_anno))) };
(s $statement_text:expr) => {
{
let tokens: Vec<::tokenizing::Token> = tokenize($statement_text);
let mut parser = super::Parser::new(tokens);
parser.statement().unwrap()
}
}
}
macro_rules! ty {
($name:expr) => { Singleton(tys!($name)) }
}
@ -1166,6 +1155,13 @@ mod parse_tests {
($expr_type:expr) => { Statement::ExpressionStatement(Expression($expr_type, None)) };
($expr_type:expr, $type_anno:expr) => { Statement::ExpressionStatement(Expression($expr_type, Some($type_anno))) };
($op:expr, $lhs:expr, $rhs:expr) => { Statement::ExpressionStatement(ex!(binexp!($op, $lhs, $rhs))) };
(s $statement_text:expr) => {
{
let tokens: Vec<::tokenizing::Token> = tokenize($statement_text);
let mut parser = super::Parser::new(tokens);
parser.statement().unwrap()
}
}
}
#[test]
@ -1179,46 +1175,46 @@ mod parse_tests {
parse_test! {"0xff", single_expr!(NatLiteral(255)) };
parse_test! {"0xf_f_", single_expr!(NatLiteral(255)) };
parse_test!("0xf_f_+1", AST(vec![exprstatement!(binexp!("+", NatLiteral(255), NatLiteral(1)))]));
parse_test!("0xf_f_+1", AST(vec![exst!(binexp!("+", NatLiteral(255), NatLiteral(1)))]));
parse_test! {"3; 4; 4.3", AST(
vec![exprstatement!(NatLiteral(3)), exprstatement!(NatLiteral(4)),
exprstatement!(FloatLiteral(4.3))])
vec![exst!(NatLiteral(3)), exst!(NatLiteral(4)),
exst!(FloatLiteral(4.3))])
};
parse_test!("1 + 2 * 3", AST(vec!
[
exprstatement!(binexp!("+", NatLiteral(1), binexp!("*", NatLiteral(2), NatLiteral(3))))
exst!(binexp!("+", NatLiteral(1), binexp!("*", NatLiteral(2), NatLiteral(3))))
]));
parse_test!("1 * 2 + 3", AST(vec!
[
exprstatement!(binexp!("+", binexp!("*", NatLiteral(1), NatLiteral(2)), NatLiteral(3)))
exst!(binexp!("+", binexp!("*", NatLiteral(1), NatLiteral(2)), NatLiteral(3)))
]));
parse_test!("1 && 2", AST(vec![exprstatement!(binexp!("&&", NatLiteral(1), NatLiteral(2)))]));
parse_test!("1 && 2", AST(vec![exst!(binexp!("&&", NatLiteral(1), NatLiteral(2)))]));
parse_test!("1 + 2 * 3 + 4", AST(vec![exprstatement!(
parse_test!("1 + 2 * 3 + 4", AST(vec![exst!(
binexp!("+",
binexp!("+", NatLiteral(1), binexp!("*", NatLiteral(2), NatLiteral(3))),
NatLiteral(4)))]));
parse_test!("(1 + 2) * 3", AST(vec!
[exprstatement!(binexp!("*", binexp!("+", NatLiteral(1), NatLiteral(2)), NatLiteral(3)))]));
[exst!(binexp!("*", binexp!("+", NatLiteral(1), NatLiteral(2)), NatLiteral(3)))]));
parse_test!(".1 + .2", AST(vec![exprstatement!(binexp!("+", FloatLiteral(0.1), FloatLiteral(0.2)))]));
parse_test!("1 / 2", AST(vec![exprstatement!(binexp!("/", NatLiteral(1), NatLiteral(2)))]));
parse_test!(".1 + .2", AST(vec![exst!(binexp!("+", FloatLiteral(0.1), FloatLiteral(0.2)))]));
parse_test!("1 / 2", AST(vec![exst!(binexp!("/", NatLiteral(1), NatLiteral(2)))]));
}
#[test]
fn parsing_tuples() {
parse_test!("()", AST(vec![exprstatement!(TupleLiteral(vec![]))]));
parse_test!("(\"hella\", 34)", AST(vec![exprstatement!(
parse_test!("()", AST(vec![exst!(TupleLiteral(vec![]))]));
parse_test!("(\"hella\", 34)", AST(vec![exst!(
TupleLiteral(
vec![ex!(s r#""hella""#), ex!(s "34")]
)
)]));
parse_test!("((1+2), \"slough\")", AST(vec![exprstatement!(TupleLiteral(vec![
parse_test!("((1+2), \"slough\")", AST(vec![exst!(TupleLiteral(vec![
ex!(binexp!("+", NatLiteral(1), NatLiteral(2))),
ex!(StringLiteral(rc!(slough))),
]))]))
@ -1226,41 +1222,41 @@ mod parse_tests {
#[test]
fn parsing_identifiers() {
parse_test!("a", AST(vec![exprstatement!(val!("a"))]));
parse_test!("a + b", AST(vec![exprstatement!(binexp!("+", val!("a"), val!("b")))]));
parse_test!("a", AST(vec![exst!(val!("a"))]));
parse_test!("a + b", AST(vec![exst!(binexp!("+", val!("a"), val!("b")))]));
//parse_test!("a[b]", AST(vec![Expression(
//parse_test!("a[]", <- TODO THIS NEEDS TO FAIL
//parse_test!(damn()[a] ,<- TODO needs to succeed
parse_test!("a[b,c]", AST(vec![exprstatement!(Index { indexee: bx!(ex!(val!("a"))), indexers: vec![ex!(val!("b")), ex!(val!("c"))]} )]));
parse_test!("a[b,c]", AST(vec![exst!(Index { indexee: bx!(ex!(val!("a"))), indexers: vec![ex!(val!("b")), ex!(val!("c"))]} )]));
parse_test!("None", AST(vec![exprstatement!(val!("None"))]));
parse_test!("None", AST(vec![exst!(val!("None"))]));
parse_test!("Pandas { a: x + y }", AST(vec![
exprstatement!(NamedStruct { name: rc!(Pandas), fields: vec![(rc!(a), ex!(binexp!("+", val!("x"), val!("y"))))]})
exst!(NamedStruct { name: rc!(Pandas), fields: vec![(rc!(a), ex!(binexp!("+", val!("x"), val!("y"))))]})
]));
}
#[test]
fn parsing_complicated_operators() {
parse_test!("a <- b", AST(vec![exprstatement!(binexp!("<-", val!("a"), val!("b")))]));
parse_test!("a || b", AST(vec![exprstatement!(binexp!("||", val!("a"), val!("b")))]));
parse_test!("a<>b", AST(vec![exprstatement!(binexp!("<>", val!("a"), val!("b")))]));
parse_test!("a.b.c.d", AST(vec![exprstatement!(binexp!(".",
parse_test!("a <- b", AST(vec![exst!(binexp!("<-", val!("a"), val!("b")))]));
parse_test!("a || b", AST(vec![exst!(binexp!("||", val!("a"), val!("b")))]));
parse_test!("a<>b", AST(vec![exst!(binexp!("<>", val!("a"), val!("b")))]));
parse_test!("a.b.c.d", AST(vec![exst!(binexp!(".",
binexp!(".",
binexp!(".", val!("a"), val!("b")),
val!("c")),
val!("d")))]));
parse_test!("-3", AST(vec![exprstatement!(prefexp!("-", NatLiteral(3)))]));
parse_test!("-0.2", AST(vec![exprstatement!(prefexp!("-", FloatLiteral(0.2)))]));
parse_test!("!3", AST(vec![exprstatement!(prefexp!("!", NatLiteral(3)))]));
parse_test!("a <- -b", AST(vec![exprstatement!(binexp!("<-", val!("a"), prefexp!("-", val!("b"))))]));
parse_test!("a <--b", AST(vec![exprstatement!(binexp!("<--", val!("a"), val!("b")))]));
parse_test!("-3", AST(vec![exst!(prefexp!("-", NatLiteral(3)))]));
parse_test!("-0.2", AST(vec![exst!(prefexp!("-", FloatLiteral(0.2)))]));
parse_test!("!3", AST(vec![exst!(prefexp!("!", NatLiteral(3)))]));
parse_test!("a <- -b", AST(vec![exst!(binexp!("<-", val!("a"), prefexp!("-", val!("b"))))]));
parse_test!("a <--b", AST(vec![exst!(binexp!("<--", val!("a"), val!("b")))]));
}
#[test]
fn parsing_functions() {
parse_test!("fn oi()", AST(vec![Declaration(FuncSig(Signature { name: rc!(oi), operator: false, params: vec![], type_anno: None }))]));
parse_test!("oi()", AST(vec![exprstatement!(Call { f: bx!(ex!(val!("oi"))), arguments: vec![] })]));
parse_test!("oi(a, 2 + 2)", AST(vec![exprstatement!(Call
parse_test!("oi()", AST(vec![exst!(Call { f: bx!(ex!(val!("oi"))), arguments: vec![] })]));
parse_test!("oi(a, 2 + 2)", AST(vec![exst!(Call
{ f: bx!(ex!(val!("oi"))),
arguments: vec![ex!(val!("a")), ex!(binexp!("+", NatLiteral(2), NatLiteral(2)))]
})]));
@ -1274,10 +1270,10 @@ mod parse_tests {
parse_test!("fn a(x) { x() }", AST(vec![Declaration(
FuncDecl(Signature { name: rc!(a), operator: false, params: vec![(rc!(x),None)], type_anno: None },
vec![exprstatement!(Call { f: bx!(ex!(val!("x"))), arguments: vec![] })]))]));
vec![exst!(Call { f: bx!(ex!(val!("x"))), arguments: vec![] })]))]));
parse_test!("fn a(x) {\n x() }", AST(vec![Declaration(
FuncDecl(Signature { name: rc!(a), operator: false, params: vec![(rc!(x),None)], type_anno: None },
vec![exprstatement!(Call { f: bx!(ex!(val!("x"))), arguments: vec![] })]))]));
vec![exst!(Call { f: bx!(ex!(val!("x"))), arguments: vec![] })]))]));
let multiline = r#"
fn a(x) {
@ -1286,7 +1282,7 @@ fn a(x) {
"#;
parse_test!(multiline, AST(vec![Declaration(
FuncDecl(Signature { name: rc!(a), operator: false, params: vec![(rc!(x),None)], type_anno: None },
vec![exprstatement!(Call { f: bx!(ex!(val!("x"))), arguments: vec![] })]))]));
vec![exst!(Call { f: bx!(ex!(val!("x"))), arguments: vec![] })]))]));
let multiline2 = r#"
fn a(x) {
@ -1296,19 +1292,19 @@ fn a(x) {
"#;
parse_test!(multiline2, AST(vec![Declaration(
FuncDecl(Signature { name: rc!(a), operator: false, params: vec![(rc!(x),None)], type_anno: None },
vec![exprstatement!(Call { f: bx!(ex!(val!("x"))), arguments: vec![] })]))]));
vec![exst!(Call { f: bx!(ex!(val!("x"))), arguments: vec![] })]))]));
}
#[test]
fn parsing_bools() {
parse_test!("false", AST(vec![exprstatement!(BoolLiteral(false))]));
parse_test!("true", AST(vec![exprstatement!(BoolLiteral(true))]));
parse_test!("false", AST(vec![exst!(BoolLiteral(false))]));
parse_test!("true", AST(vec![exst!(BoolLiteral(true))]));
}
#[test]
fn parsing_strings() {
parse_test!(r#""hello""#, AST(vec![exprstatement!(StringLiteral(rc!(hello)))]));
parse_test!(r#""hello""#, AST(vec![exst!(StringLiteral(rc!(hello)))]));
}
#[test]
@ -1351,14 +1347,14 @@ fn a(x) {
#[test]
fn parsing_block_expressions() {
parse_test! {
"if a() then { b(); c() }", AST(vec![exprstatement!(
"if a() then { b(); c() }", AST(vec![exst!(
IfExpression {
discriminator: bx! {
Discriminator::Simple(ex!(Call { f: bx!(ex!(val!("a"))), arguments: vec![]}))
},
body: bx! {
IfExpressionBody::SimpleConditional(
vec![exprstatement!(Call { f: bx!(ex!(val!("b"))), arguments: vec![]}), exprstatement!(Call { f: bx!(ex!(val!("c"))), arguments: vec![] })],
vec![exst!(Call { f: bx!(ex!(val!("b"))), arguments: vec![]}), exst!(Call { f: bx!(ex!(val!("c"))), arguments: vec![] })],
None
)
}
@ -1367,16 +1363,16 @@ fn a(x) {
};
parse_test! {
"if a() then { b(); c() } else { q }", AST(vec![exprstatement!(
"if a() then { b(); c() } else { q }", AST(vec![exst!(
IfExpression {
discriminator: bx! {
Discriminator::Simple(ex!(Call { f: bx!(ex!(val!("a"))), arguments: vec![]}))
},
body: bx! {
IfExpressionBody::SimpleConditional(
vec![exprstatement!(Call { f: bx!(ex!(val!("b"))), arguments: vec![]}), exprstatement!(Call { f: bx!(ex!(val!("c"))), arguments: vec![] })],
vec![exst!(Call { f: bx!(ex!(val!("b"))), arguments: vec![]}), exst!(Call { f: bx!(ex!(val!("c"))), arguments: vec![] })],
Some(
vec![exprstatement!(val!("q"))],
vec![exst!(val!("q"))],
)
)
}
@ -1385,9 +1381,9 @@ fn a(x) {
};
/*
parse_test!("if a() then { b(); c() }", AST(vec![exprstatement!(
parse_test!("if a() then { b(); c() }", AST(vec![exst!(
IfExpression(bx!(ex!(Call { f: bx!(ex!(val!("a"))), arguments: vec![]})),
vec![exprstatement!(Call { f: bx!(ex!(val!("b"))), arguments: vec![]}), exprstatement!(Call { f: bx!(ex!(val!("c"))), arguments: vec![] })],
vec![exst!(Call { f: bx!(ex!(val!("b"))), arguments: vec![]}), exst!(Call { f: bx!(ex!(val!("c"))), arguments: vec![] })],
None)
)]));
parse_test!(r#"
@ -1397,21 +1393,21 @@ fn a(x) {
} else {
c
}"#,
AST(vec![exprstatement!(IfExpression(bx!(ex!(BoolLiteral(true))),
AST(vec![exst!(IfExpression(bx!(ex!(BoolLiteral(true))),
vec![Declaration(Binding { name: rc!(a), constant: true, expr: ex!(NatLiteral(10)) }),
exprstatement!(val!(rc!(b)))],
Some(vec![exprstatement!(val!(rc!(c)))])))])
exst!(val!(rc!(b)))],
Some(vec![exst!(val!(rc!(c)))])))])
);
parse_test!("if a { b } else { c }", AST(vec![exprstatement!(
parse_test!("if a { b } else { c }", AST(vec![exst!(
IfExpression(bx!(ex!(val!("a"))),
vec![exprstatement!(val!("b"))],
Some(vec![exprstatement!(val!("c"))])))]));
vec![exst!(val!("b"))],
Some(vec![exst!(val!("c"))])))]));
parse_test!("if (A {a: 1}) { b } else { c }", AST(vec![exprstatement!(
parse_test!("if (A {a: 1}) { b } else { c }", AST(vec![exst!(
IfExpression(bx!(ex!(NamedStruct { name: rc!(A), fields: vec![(rc!(a), ex!(NatLiteral(1)))]})),
vec![exprstatement!(val!("b"))],
Some(vec![exprstatement!(val!("c"))])))]));
vec![exst!(val!("b"))],
Some(vec![exst!(val!("c"))])))]));
parse_error!("if A {a: 1} { b } else { c }");
*/
@ -1465,21 +1461,21 @@ fn a(x) {
Expression(val!("b"), Some(ty!("Int"))) })]));
parse_test!("a : Int", AST(vec![
exprstatement!(val!("a"), ty!("Int"))
exst!(val!("a"), ty!("Int"))
]));
parse_test!("a : Option<Int>", AST(vec![
exprstatement!(val!("a"), Singleton(TypeSingletonName { name: rc!(Option), params: vec![ty!("Int")] }))
exst!(val!("a"), Singleton(TypeSingletonName { name: rc!(Option), params: vec![ty!("Int")] }))
]));
parse_test!("a : KoreanBBQSpecifier<Kimchi, Option<Bulgogi> >", AST(vec![
exprstatement!(val!("a"), Singleton(TypeSingletonName { name: rc!(KoreanBBQSpecifier), params: vec![
exst!(val!("a"), Singleton(TypeSingletonName { name: rc!(KoreanBBQSpecifier), params: vec![
ty!("Kimchi"), Singleton(TypeSingletonName { name: rc!(Option), params: vec![ty!("Bulgogi")] })
] }))
]));
parse_test!("a : (Int, Yolo<a>)", AST(vec![
exprstatement!(val!("a"), Tuple(
exst!(val!("a"), Tuple(
vec![ty!("Int"), Singleton(TypeSingletonName {
name: rc!(Yolo), params: vec![ty!("a")]
})]))]));
@ -1492,7 +1488,7 @@ fn a(x) {
) }
parse_test!(r#"\ (x: Int, y) { a;b;c;}"#, AST(vec![
exprstatement!(Lambda {
exst!(Lambda {
params: vec![(rc!(x), Some(ty!("Int"))), (rc!(y), None)],
type_anno: None,
body: vec![exst!(val!("a")), exst!(val!("b")), exst!(val!("c"))]
@ -1500,21 +1496,21 @@ fn a(x) {
]));
parse_test!(r#"\(x){y}(1)"#, AST(vec![
exprstatement!(Call { f: bx!(ex!(
exst!(Call { f: bx!(ex!(
Lambda {
params: vec![(rc!(x), None)],
type_anno: None,
body: vec![exprstatement!(val!("y"))] }
body: vec![exst!(val!("y"))] }
)),
arguments: vec![ex!(NatLiteral(1))] })]));
parse_test! {
r#"\(x: Int): String { "q" }"#,
AST(vec![
exprstatement!(Lambda {
exst!(Lambda {
params: vec![(rc!(x), Some(ty!("Int")))],
type_anno: Some(ty!("String")),
body: vec![exprstatement!(s r#""q""#)]
body: vec![exst!(s r#""q""#)]
})
])
}
@ -1524,7 +1520,7 @@ fn a(x) {
fn list_literals() {
parse_test! {
"[1,2]", AST(vec![
exprstatement!(ListLiteral(vec![ex!(NatLiteral(1)), ex!(NatLiteral(2))]))])
exst!(ListLiteral(vec![ex!(NatLiteral(1)), ex!(NatLiteral(2))]))])
};
}
@ -1532,12 +1528,12 @@ fn a(x) {
fn while_expr() {
parse_test! {
"while { }", AST(vec![
exprstatement!(WhileExpression { condition: None, body: vec![] })])
exst!(WhileExpression { condition: None, body: vec![] })])
}
parse_test! {
"while a == b { }", AST(vec![
exprstatement!(WhileExpression { condition: Some(bx![ex![binexp!("==", val!("a"), val!("b"))]]), body: vec![] })])
exst!(WhileExpression { condition: Some(bx![ex![binexp!("==", val!("a"), val!("b"))]]), body: vec![] })])
}
}
@ -1545,7 +1541,7 @@ fn a(x) {
fn for_expr() {
parse_test! {
"for { a <- maybeValue } return 1", AST(vec![
exprstatement!(ForExpression {
exst!(ForExpression {
enumerators: vec![Enumerator { id: rc!(a), generator: ex!(val!("maybeValue")) }],
body: bx!(MonadicReturn(ex!(NatLiteral(1))))
})])
@ -1553,8 +1549,8 @@ fn a(x) {
parse_test! {
"for n <- someRange { f(n); }", AST(vec![
exprstatement!(ForExpression { enumerators: vec![Enumerator { id: rc!(n), generator: ex!(val!("someRange"))}],
body: bx!(ForBody::StatementBlock(vec![exprstatement!(Call { f: bx![ex!(val!("f"))], arguments: vec![ex!(val!("n"))] })]))
exst!(ForExpression { enumerators: vec![Enumerator { id: rc!(n), generator: ex!(val!("someRange"))}],
body: bx!(ForBody::StatementBlock(vec![exst!(Call { f: bx![ex!(val!("f"))], arguments: vec![ex!(val!("n"))] })]))
})])
}
}
@ -1563,27 +1559,27 @@ fn a(x) {
fn patterns() {
parse_test! {
"if x is Some(a) then { 4 } else { 9 }", AST(vec![
exprstatement!(
exst!(
IfExpression {
discriminator: bx!(Discriminator::Simple(ex!(Value(rc!(x))))),
body: bx!(IfExpressionBody::SimplePatternMatch(Pattern::TupleStruct(rc!(Some), vec![Pattern::Literal(PatternLiteral::VarPattern(rc!(a)))]), vec![exprstatement!(NatLiteral(4))], Some(vec![exprstatement!(NatLiteral(9))]))) }
body: bx!(IfExpressionBody::SimplePatternMatch(Pattern::TupleStruct(rc!(Some), vec![Pattern::Literal(PatternLiteral::VarPattern(rc!(a)))]), vec![exst!(NatLiteral(4))], Some(vec![exst!(NatLiteral(9))]))) }
)
])
}
parse_test! {
"if x is Some(a) then 4 else 9", AST(vec![
exprstatement!(
exst!(
IfExpression {
discriminator: bx!(Discriminator::Simple(ex!(Value(rc!(x))))),
body: bx!(IfExpressionBody::SimplePatternMatch(Pattern::TupleStruct(rc!(Some), vec![Pattern::Literal(PatternLiteral::VarPattern(rc!(a)))]), vec![exprstatement!(NatLiteral(4))], Some(vec![exprstatement!(NatLiteral(9))]))) }
body: bx!(IfExpressionBody::SimplePatternMatch(Pattern::TupleStruct(rc!(Some), vec![Pattern::Literal(PatternLiteral::VarPattern(rc!(a)))]), vec![exst!(NatLiteral(4))], Some(vec![exst!(NatLiteral(9))]))) }
)
])
}
parse_test! {
"if x is Something { a, b: x } then { 4 } else { 9 }", AST(vec![
exprstatement!(
exst!(
IfExpression {
discriminator: bx!(Discriminator::Simple(ex!(Value(rc!(x))))),
body: bx!(IfExpressionBody::SimplePatternMatch(
@ -1591,7 +1587,7 @@ fn a(x) {
(rc!(a),Pattern::Literal(PatternLiteral::StringPattern(rc!(a)))),
(rc!(b),Pattern::Literal(PatternLiteral::VarPattern(rc!(x))))
]),
vec![exprstatement!(NatLiteral(4))], Some(vec![exprstatement!(NatLiteral(9))])))
vec![exst!(NatLiteral(4))], Some(vec![exst!(NatLiteral(9))])))
}
)
])
@ -1603,13 +1599,13 @@ fn a(x) {
fn pattern_literals() {
parse_test! {
"if x is -1 then 1 else 2", AST(vec![
exprstatement!(
exst!(
IfExpression {
discriminator: bx!(Discriminator::Simple(ex!(Value(rc!(x))))),
body: bx!(IfExpressionBody::SimplePatternMatch(
Pattern::Literal(PatternLiteral::NumPattern { neg: true, num: NatLiteral(1) }),
vec![exprstatement!(NatLiteral(1))],
Some(vec![exprstatement!(NatLiteral(2))]),
vec![exst!(NatLiteral(1))],
Some(vec![exst!(NatLiteral(2))]),
))
}
)
@ -1618,13 +1614,13 @@ fn a(x) {
parse_test! {
"if x is 1 then 1 else 2", AST(vec![
exprstatement!(
exst!(
IfExpression {
discriminator: bx!(Discriminator::Simple(ex!(Value(rc!(x))))),
body: bx!(IfExpressionBody::SimplePatternMatch(
Pattern::Literal(PatternLiteral::NumPattern { neg: false, num: NatLiteral(1) }),
vec![exprstatement!(NatLiteral(1))],
Some(vec![exprstatement!(NatLiteral(2))]),
vec![exst!(NatLiteral(1))],
Some(vec![exst!(NatLiteral(2))]),
))
}
)
@ -1633,13 +1629,13 @@ fn a(x) {
parse_test! {
"if x is true then 1 else 2", AST(vec![
exprstatement!(
exst!(
IfExpression {
discriminator: bx!(Discriminator::Simple(ex!(Value(rc!(x))))),
body: bx!(IfExpressionBody::SimplePatternMatch(
Pattern::Literal(PatternLiteral::BoolPattern(true)),
vec![exprstatement!(NatLiteral(1))],
Some(vec![exprstatement!(NatLiteral(2))]),
vec![exst!(NatLiteral(1))],
Some(vec![exst!(NatLiteral(2))]),
))
}
)
@ -1648,13 +1644,13 @@ fn a(x) {
parse_test! {
"if x is \"gnosticism\" then 1 else 2", AST(vec![
exprstatement!(
exst!(
IfExpression {
discriminator: bx!(Discriminator::Simple(ex!(Value(rc!(x))))),
body: bx!(IfExpressionBody::SimplePatternMatch(
Pattern::Literal(PatternLiteral::StringPattern(rc!(gnosticism))),
vec![exprstatement!(NatLiteral(1))],
Some(vec![exprstatement!(NatLiteral(2))]),
vec![exst!(NatLiteral(1))],
Some(vec![exst!(NatLiteral(2))]),
))
}
)