wip operator tests

This commit is contained in:
mhoffm
2021-06-13 09:26:15 +02:00
parent 3bba72f836
commit c1dd2b1c5a
2 changed files with 52 additions and 1 deletions

View File

@@ -21,7 +21,8 @@ resource_1 "strlit1" "strlit2" {
for5 = { for v in local.list : v => v } for5 = { for v in local.list : v => v }
for6 = [ for v in local.list : v if v < 3 ] for6 = [ for v in local.list : v if v < 3 ]
func1 = is_number("123") func1 = is_number("123")
cond1 = pred() ? 1 : "foobar" cond1 = (1 == 2) ? 1 : "foobar"
bin1 = ((1+2)%3)*4
esc1 = "\" \t \UFF11FF22 \uFFFF \n" esc1 = "\" \t \UFF11FF22 \uFFFF \n"
nested_resource_1 { nested_resource_1 {

50
test/corpus/operators.txt Normal file
View File

@@ -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)))))))))