From c1dd2b1c5ab0816b5925fb94f7a280b237a7c05f Mon Sep 17 00:00:00 2001 From: mhoffm Date: Sun, 13 Jun 2021 09:26:15 +0200 Subject: [PATCH] wip operator tests --- example/example.hcl | 3 ++- test/corpus/operators.txt | 50 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 test/corpus/operators.txt diff --git a/example/example.hcl b/example/example.hcl index a6a921b..c601173 100644 --- a/example/example.hcl +++ b/example/example.hcl @@ -21,7 +21,8 @@ resource_1 "strlit1" "strlit2" { for5 = { for v in local.list : v => v } for6 = [ for v in local.list : v if v < 3 ] func1 = is_number("123") - cond1 = pred() ? 1 : "foobar" + cond1 = (1 == 2) ? 1 : "foobar" + bin1 = ((1+2)%3)*4 esc1 = "\" \t \UFF11FF22 \uFFFF \n" nested_resource_1 { diff --git a/test/corpus/operators.txt b/test/corpus/operators.txt new file mode 100644 index 0000000..f3df9cc --- /dev/null +++ b/test/corpus/operators.txt @@ -0,0 +1,50 @@ +================== +unary operator - +================== + +foo = -3 + +--- + +(config_file + (body + (attribute + (identifier) + (expression + (operation + (unary_operation (expr_term (literal_value (numeric_lit))))))))) + +================== +unary operator ! +================== + +foo = !true + +--- + +(config_file + (body + (attribute + (identifier) + (expression + (operation + (unary_operation (expr_term (literal_value (bool_lit))))))))) + +================== +binary operators + +================== + +foo = 1+2 + +--- + +(config_file + (body + (attribute + (identifier) + (expression + (operation + (binary_operation + (expr_term (literal_value (numeric_lit))) + (expr_term (literal_value (numeric_lit))))))))) +