From db922925697e31a3891a7b11e60410e02e2e84ef Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 5 Jan 2017 02:36:28 -0800 Subject: [PATCH] Fixed all tests --- src/parser.rs | 14 +++++++------- src/tokenizer.rs | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index 00be9c5..22bbde6 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -489,32 +489,32 @@ mod tests { "fn a() 1 + 2 end", &[FuncDefNode(Function {prototype: Prototype { ref name, ref parameters }, ref body})], match &body[..] { &[ExprNode(BinExp(_, box Number(1.0), box Number(2.0)))] => true, _ => false } - && name == "a" && match ¶meters[..] { &[] => true, _ => false } + && **name == "a" && match ¶meters[..] { &[] => true, _ => false } ); parsetest!( "fn a(x,y) 1 + 2 end", &[FuncDefNode(Function {prototype: Prototype { ref name, ref parameters }, ref body})], match &body[..] { &[ExprNode(BinExp(_, box Number(1.0), box Number(2.0)))] => true, _ => false } - && name == "a" && *parameters == ["x","y"] + && **name == "a" && *parameters[0] == "x" && *parameters[1] == "y" && parameters.len() == 2 ); } #[test] fn expression_parse_test() { - parsetest!("a", &[ExprNode(Variable(ref s))], s == "a"); + parsetest!("a", &[ExprNode(Variable(ref s))], **s == "a"); parsetest!("a + b", &[ExprNode(BinExp(ref plus, box Variable(ref a), box Variable(ref b)))], - plus == "+" && a == "a" && b == "b"); + **plus == "+" && **a == "a" && **b == "b"); parsetest!("a + b * c", &[ExprNode(BinExp(ref plus, box Variable(ref a), box BinExp(ref mul, box Variable(ref b), box Variable(ref c))))], - plus == "+" && mul == "*" && a == "a" && b == "b" && c == "c"); + **plus == "+" && **mul == "*" && **a == "a" && **b == "b" && **c == "c"); parsetest!("a * b + c", &[ExprNode(BinExp(ref plus, box BinExp(ref mul, box Variable(ref a), box Variable(ref b)), box Variable(ref c)))], - plus == "+" && mul == "*" && a == "a" && b == "b" && c == "c"); + **plus == "+" && **mul == "*" && **a == "a" && **b == "b" && **c == "c"); parsetest!("(a + b) * c", &[ExprNode(BinExp(ref mul, box BinExp(ref plus, box Variable(ref a), box Variable(ref b)), box Variable(ref c)))], - plus == "+" && mul == "*" && a == "a" && b == "b" && c == "c"); + **plus == "+" && **mul == "*" && **a == "a" && **b == "b" && **c == "c"); } #[test] diff --git a/src/tokenizer.rs b/src/tokenizer.rs index fcbb793..cce9b7e 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -162,19 +162,19 @@ mod tests { fn basic_tokeniziation_tests() { token_test!("let a = 3\n", [Keyword(Kw::Let), Identifier(ref a), Operator(Op(ref b)), NumLiteral(3.0), Newline], - a == "a" && b == "="); + **a == "a" && **b == "="); token_test!("2+1", [NumLiteral(2.0), Operator(Op(ref a)), NumLiteral(1.0)], - a == "+"); + **a == "+"); token_test!("2 + 1", [NumLiteral(2.0), Operator(Op(ref a)), NumLiteral(1.0)], - a == "+"); + **a == "+"); token_test!("2.3*49.2", [NumLiteral(2.3), Operator(Op(ref a)), NumLiteral(49.2)], - a == "*"); + **a == "*"); assert!(tokenize("2.4.5").is_err()); } @@ -182,15 +182,15 @@ mod tests { #[test] fn string_test() { token_test!("null + \"a string\"", - [Keyword(Kw::Null), Operator(Op(ref a)), StrgLiteral(ref b)], - a == "+" && b == "a string"); + [Keyword(Kw::Null), Operator(Op(ref a)), StrLiteral(ref b)], + **a == "+" && **b == "a string"); } #[test] fn operator_test() { token_test!("a *> b", [Identifier(ref a), Operator(Op(ref b)), Identifier(ref c)], - a == "a" && b == "*>" && c == "b"); + **a == "a" && **b == "*>" && **c == "b"); }