diff --git a/src/expression/Expression_test.go b/src/expression/Expression_test.go index 1303305..3954923 100644 --- a/src/expression/Expression_test.go +++ b/src/expression/Expression_test.go @@ -9,132 +9,6 @@ import ( "git.urbach.dev/go/assert" ) -func TestParse(t *testing.T) { - tests := []struct { - Name string - Expression string - Result string - }{ - {"Identity", "1", "1"}, - {"Basic calculation", "1+2", "(+ 1 2)"}, - - {"Same operator", "1+2+3", "(+ (+ 1 2) 3)"}, - {"Same operator 2", "1+2+3+4", "(+ (+ (+ 1 2) 3) 4)"}, - - {"Different operator", "1+2-3", "(- (+ 1 2) 3)"}, - {"Different operator 2", "1+2-3+4", "(+ (- (+ 1 2) 3) 4)"}, - {"Different operator 3", "1+2-3+4-5", "(- (+ (- (+ 1 2) 3) 4) 5)"}, - - {"Grouped identity", "(1)", "1"}, - {"Grouped identity 2", "((1))", "1"}, - {"Grouped identity 3", "(((1)))", "1"}, - - {"Adding identity", "(1)+(2)", "(+ 1 2)"}, - {"Adding identity 2", "(1)+(2)+(3)", "(+ (+ 1 2) 3)"}, - {"Adding identity 3", "(1)+(2)+(3)+(4)", "(+ (+ (+ 1 2) 3) 4)"}, - - {"Grouping", "(1+2)", "(+ 1 2)"}, - {"Grouping 2", "(1+2+3)", "(+ (+ 1 2) 3)"}, - {"Grouping 3", "((1)+(2)+(3))", "(+ (+ 1 2) 3)"}, - {"Grouping left", "(1+2)*3", "(* (+ 1 2) 3)"}, - {"Grouping right", "1*(2+3)", "(* 1 (+ 2 3))"}, - {"Grouping same operator", "1+(2+3)", "(+ 1 (+ 2 3))"}, - {"Grouping same operator 2", "1+(2+3)+(4+5)", "(+ (+ 1 (+ 2 3)) (+ 4 5))"}, - - {"Two groups", "(1+2)*(3+4)", "(* (+ 1 2) (+ 3 4))"}, - {"Two groups 2", "(1+2-3)*(3+4-5)", "(* (- (+ 1 2) 3) (- (+ 3 4) 5))"}, - {"Two groups 3", "(1+2)*(3+4-5)", "(* (+ 1 2) (- (+ 3 4) 5))"}, - - {"Operator priority", "1+2*3", "(+ 1 (* 2 3))"}, - {"Operator priority 2", "1*2+3", "(+ (* 1 2) 3)"}, - {"Operator priority 3", "1+2*3+4", "(+ (+ 1 (* 2 3)) 4)"}, - {"Operator priority 4", "1+2*(3+4)+5", "(+ (+ 1 (* 2 (+ 3 4))) 5)"}, - {"Operator priority 5", "1+2*3*4", "(+ 1 (* (* 2 3) 4))"}, - {"Operator priority 6", "1+2*3+4*5", "(+ (+ 1 (* 2 3)) (* 4 5))"}, - {"Operator priority 7", "1+2*3*4*5*6", "(+ 1 (* (* (* (* 2 3) 4) 5) 6))"}, - {"Operator priority 8", "1*2*3+4*5*6", "(+ (* (* 1 2) 3) (* (* 4 5) 6))"}, - - {"Complex", "(1+2-3*4)*(5+6-7*8)", "(* (- (+ 1 2) (* 3 4)) (- (+ 5 6) (* 7 8)))"}, - {"Complex 2", "(1+2*3-4)*(5+6*7-8)", "(* (- (+ 1 (* 2 3)) 4) (- (+ 5 (* 6 7)) 8))"}, - {"Complex 3", "(1+2*3-4)*(5+6*7-8)+9-10*11", "(- (+ (* (- (+ 1 (* 2 3)) 4) (- (+ 5 (* 6 7)) 8)) 9) (* 10 11))"}, - - {"Unary not", "!", "!"}, - {"Unary not 2", "!a", "(! a)"}, - {"Unary not 3", "!(!a)", "(! (! a))"}, - {"Unary not 4", "!(a||b)", "(! (|| a b))"}, - {"Unary not 5", "a || !b", "(|| a (! b))"}, - - {"Unary minus", "-", "-"}, - {"Unary minus 2", "-a", "(- a)"}, - {"Unary minus 3", "-(-a)", "(- (- a))"}, - {"Unary minus 4", "-a+b", "(+ (- a) b)"}, - {"Unary minus 5", "-(a+b)", "(- (+ a b))"}, - {"Unary minus 6", "a + -b", "(+ a (- b))"}, - {"Unary minus 7", "-a + -b", "(+ (- a) (- b))"}, - - {"Assign bitwise operation", "a|=b", "(|= a b)"}, - {"Assign bitwise operation 2", "a|=b<