package parser_test import ( "tokenizer" "parser" "io/ioutil" "testing" ) func TestParserDeclaration(t *testing.T) { got := getCompiled(t, "test/tokenizer_var.asl") want := "x = 1;\r\narray = [1,2,3];\r\n" equal(t, got, want) } func TestParserAssignment(t *testing.T) { got := getCompiled(t, "test/parser_assignment.asl") want := "x = 1;\r\n" equal(t, got, want) } func TestParserIf(t *testing.T) { got := getCompiled(t, "test/tokenizer_if.asl") want := "if (ab;\r\n};\r\n[1+3/4, 2-(66*22)/3-((123))] call myFunc;\r\n" equal(t, got, want) } func TestParserBuildinFunctionCall(t *testing.T) { got := getCompiled(t, "test/parser_buildin_func.asl") want := "_x = (([player, foo] getVar bar) setHit [\"head\", \"tail\"]);\r\n" equal(t, got, want) } func TestParserOperator(t *testing.T) { got := getCompiled(t, "test/parser_operator.asl") want := "if (x==y&&x!=y&&x<=y&&x>=y&&xy) then {\r\n};\r\n" equal(t, got, want) } func TestParserTryCatch(t *testing.T) { got := getCompiled(t, "test/parser_try_catch.asl") want := "try {\r\n} catch {\r\n};\r\n" equal(t, got, want) } func TestParserNegationFunctionCall(t *testing.T) { got := getCompiled(t, "test/parser_negation.asl") want := "x = !([] call foo);\r\n" equal(t, got, want) } func TestParserExitWith(t *testing.T) { got := getCompiled(t, "test/parser_exitwith.asl") want := "if (true) exitWith {\r\n};\r\n" equal(t, got, want) } func TestParserWaitUntil(t *testing.T) { got := getCompiled(t, "test/parser_waituntil.asl") want := "waitUntil {x=x+1;x<100};\r\n" equal(t, got, want) } func TestParserArray(t *testing.T) { got := getCompiled(t, "test/parser_array.asl") want := "x = [1,2,3];\r\ny = (x select (1));\r\n" equal(t, got, want) } func TestParserFunctionParams(t *testing.T) { got := getCompiled(t, "test/parser_func_params.asl") want := "myFunc = {\r\nparams [[\"a\",1],[\"b\",2]];\r\nreturn a+b;\r\n};\r\n" equal(t, got, want) } func TestParserInlineCode(t *testing.T) { got := getCompiled(t, "test/parser_code.asl") want := "inline_code = {a = 1;b = 2;if (a