From 717d592710f06c9aa9b13f6a00e4b01068d78e25 Mon Sep 17 00:00:00 2001 From: Erin Date: Mon, 7 Jun 2021 23:06:13 +0200 Subject: [PATCH] Added T-Dark test --- src/parser.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/parser.rs b/src/parser.rs index 19569032..aea4f891 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -499,4 +499,35 @@ mod tests { let ast = Parser::new(code).init().unwrap(); assert_eq!(ast, expected); } + + #[test] + fn tdark() { + let code = r#"T-Dark { var lang = "lang" + lang; }"#; + let expected = &[Stmt { + kind: StmtKind::Var { + iden: Iden { + iden: "script".to_string(), + span: 13..17, + }, + init: Some(Expr { + kind: ExprKind::BinOp { + lhs: Box::new(Expr { + kind: ExprKind::Literal(Value::Str("script".to_string())), + span: 20..26, + }), + rhs: Box::new(Expr { + kind: ExprKind::Variable("script".to_string()), + span: 29..33, + }), + kind: BinOpKind::Add, + }, + span: 20..33, + }), + }, + span: 9..34, + }]; + + let ast = Parser::new(code).init().unwrap(); + assert_eq!(ast, expected); + } }