Skip to content

Commit e32d3e3

Browse files
add round-trip test suite
1 parent ba80334 commit e32d3e3

19 files changed

Lines changed: 590 additions & 616 deletions

test/round_trip/__init__.py

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
locals {
2+
addition_1 = ((a + b) + c)
3+
addition_2 = a + b
4+
addition_3 = (a + b)
5+
eq_before_and = var.env == "prod" && var.debug
6+
and_before_ternary = true && true ? 1 : 0
7+
mixed_arith_cmp = var.a + var.b * var.c > 10
8+
full_chain = a + b == c && d || e
9+
left_assoc_sub = a - b - c
10+
left_assoc_mul_div = (a * b) / c
11+
nested_ternary = (a ? b : c) ? d : e
12+
unary_precedence = !a && b
13+
neg_precedence = (-a) + b
14+
neg_parentheses = -(a + b)
15+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
block label1 label2 {
3+
a = 5
4+
b = 1256.5
5+
c = 15 + (10 * 12)
6+
d = (- a)
7+
e = (
8+
a == b
9+
? true : false
10+
)
11+
f = "${"this is a string"}"
12+
g = 1 == 2
13+
h = {
14+
k1 = 5,
15+
k2 = 10
16+
,
17+
"k3" = {k4 = "a"}
18+
(5 + 5) = "d"
19+
k5.attr.attr = "e"
20+
}
21+
i = [
22+
a, b
23+
,
24+
"c${aaa}",
25+
d,
26+
[1, 2, 3,],
27+
f(a),
28+
provider::func::aa(5)
29+
30+
]
31+
j = func(
32+
a, b
33+
, c,
34+
d ...
35+
36+
)
37+
k = a.b.5
38+
l = a.*.b
39+
m = a[*][c].a.*.1
40+
41+
block b1 {
42+
a = 1
43+
}
44+
}
45+
46+
block label1 label3 {
47+
simple_interpolation = "prefix:${var}-suffix"
48+
embedded_interpolation = "(long substring without interpolation); ${"aaa-${local}-${local}"}/us-west-2/key_foo"
49+
deeply_nested_interpolation = "prefix1-${"prefix2-${"prefix3-$${foo:bar}"}"}"
50+
escaped_interpolation = "prefix:$${aws:username}-suffix"
51+
simple_and_escaped = "${"bar"}$${baz:bat}"
52+
simple_and_escaped_reversed = "$${baz:bat}${"bar"}"
53+
nested_escaped = "bar-${"$${baz:bat}"}"
54+
}
55+
56+
57+
block {
58+
route53_forwarding_rule_shares = {
59+
for forwarding_rule_key in keys(var.route53_resolver_forwarding_rule_shares) :
60+
"${forwarding_rule_key}" => {
61+
aws_account_ids = [
62+
for account_name in var.route53_resolver_forwarding_rule_shares[
63+
forwarding_rule_key
64+
].aws_account_names :
65+
module.remote_state_subaccounts.map[account_name].outputs["aws_account_id"]
66+
]
67+
}
68+
...
69+
if
70+
substr(bucket_name, 0, 1) == "l"
71+
}
72+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
locals {
2+
addition_1 = ((a + b) + c)
3+
addition_2 = a + b
4+
addition_3 = (a + b)
5+
eq_before_and = var.env == "prod" && var.debug
6+
and_before_ternary = true && true ? 1 : 0
7+
mixed_arith_cmp = var.a + var.b * var.c > 10
8+
full_chain = a + b == c && d || e
9+
left_assoc_sub = a - b - c
10+
left_assoc_mul_div = (a * b) / c
11+
nested_ternary = (a ? b : c) ? d : e
12+
unary_precedence = !a && b
13+
neg_precedence = (-a) + b
14+
neg_parentheses = -(a + b)
15+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
block label1 label2 {
2+
a = 5
3+
b = 1256.5
4+
c = 15 + (10 * 12)
5+
d = (-a)
6+
e = (a == b ? true : false)
7+
f = "${"this is a string"}"
8+
g = 1 == 2
9+
h = {
10+
k1 = 5,
11+
k2 = 10,
12+
"k3" = {
13+
k4 = "a",
14+
},
15+
(5 + 5) = "d",
16+
k5.attr.attr = "e",
17+
}
18+
i = [
19+
a,
20+
b,
21+
"c${aaa}",
22+
d,
23+
[
24+
1,
25+
2,
26+
3,
27+
],
28+
f(a),
29+
provider::func::aa(),
30+
]
31+
j = func(a, b, c, d)
32+
k = a.b.5
33+
l = a.*.b
34+
m = a[*][c].a.*.1
35+
36+
block b1 {
37+
a = 1
38+
}
39+
}
40+
41+
42+
block label1 label3 {
43+
simple_interpolation = "prefix:${var}-suffix"
44+
embedded_interpolation = "(long substring without interpolation); ${"aaa-${local}-${local}"}/us-west-2/key_foo"
45+
deeply_nested_interpolation = "prefix1-${"prefix2-${"prefix3-$${foo:bar}"}"}"
46+
escaped_interpolation = "prefix:$${aws:username}-suffix"
47+
simple_and_escaped = "${"bar"}$${baz:bat}"
48+
simple_and_escaped_reversed = "$${baz:bat}${"bar"}"
49+
nested_escaped = "bar-${"$${baz:bat}"}"
50+
}
51+
52+
53+
block {
54+
route53_forwarding_rule_shares = {
55+
for forwarding_rule_key in keys(var.route53_resolver_forwarding_rule_shares) :
56+
"${forwarding_rule_key}" => {
57+
aws_account_ids = [
58+
for account_name in var.route53_resolver_forwarding_rule_shares[forwarding_rule_key].aws_account_names :
59+
module.remote_state_subaccounts.map[account_name].outputs["aws_account_id"]
60+
61+
]
62+
} ... if substr(bucket_name, 0, 1) == "l"
63+
}
64+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"locals": [
3+
{
4+
"addition_1": "${((a + b) + c)}",
5+
"addition_2": "${a + b}",
6+
"addition_3": "${(a + b)}",
7+
"eq_before_and": "${var.env == \"prod\" && var.debug}",
8+
"and_before_ternary": "${true && true ? 1 : 0}",
9+
"mixed_arith_cmp": "${var.a + var.b * var.c > 10}",
10+
"full_chain": "${a + b == c && d || e}",
11+
"left_assoc_sub": "${a - b - c}",
12+
"left_assoc_mul_div": "${(a * b) / c}",
13+
"nested_ternary": "${(a ? b : c) ? d : e}",
14+
"unary_precedence": "${!a && b}",
15+
"neg_precedence": "${(-a) + b}",
16+
"neg_parentheses": "${-(a + b)}",
17+
"__is_block__": true
18+
}
19+
]
20+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"block": [
3+
{
4+
"label1": {
5+
"label2": {
6+
"a": 5,
7+
"b": 1256.5,
8+
"c": "${15 + (10 * 12)}",
9+
"d": "${(-a)}",
10+
"e": "${(a == b ? true : false)}",
11+
"f": "\"${\"this is a string\"}\"",
12+
"g": "${1 == 2}",
13+
"h": {
14+
"k1": 5,
15+
"k2": 10,
16+
"\"k3\"": {
17+
"k4": "\"a\""
18+
},
19+
"${(5 + 5)}": "\"d\"",
20+
"k5.attr.attr": "\"e\""
21+
},
22+
"i": [
23+
"a",
24+
"b",
25+
"\"c${aaa}\"",
26+
"d",
27+
[
28+
1,
29+
2,
30+
3
31+
],
32+
"${f(a)}",
33+
"${provider::func::aa()}"
34+
],
35+
"j": "${func(a, b, c, d)}",
36+
"k": "${a.b.5}",
37+
"l": "${a.*.b}",
38+
"m": "${a[*][c].a.*.1}",
39+
"block": [
40+
{
41+
"b1": {
42+
"a": 1,
43+
"__is_block__": true
44+
}
45+
}
46+
],
47+
"__is_block__": true
48+
}
49+
}
50+
},
51+
{
52+
"label1": {
53+
"label3": {
54+
"simple_interpolation": "\"prefix:${var}-suffix\"",
55+
"embedded_interpolation": "\"(long substring without interpolation); ${\"aaa-${local}-${local}\"}/us-west-2/key_foo\"",
56+
"deeply_nested_interpolation": "\"prefix1-${\"prefix2-${\"prefix3-$${foo:bar}\"}\"}\"",
57+
"escaped_interpolation": "\"prefix:$${aws:username}-suffix\"",
58+
"simple_and_escaped": "\"${\"bar\"}$${baz:bat}\"",
59+
"simple_and_escaped_reversed": "\"$${baz:bat}${\"bar\"}\"",
60+
"nested_escaped": "\"bar-${\"$${baz:bat}\"}\"",
61+
"__is_block__": true
62+
}
63+
}
64+
},
65+
{
66+
"route53_forwarding_rule_shares": "${{for forwarding_rule_key in keys(var.route53_resolver_forwarding_rule_shares) : \"${forwarding_rule_key}\" => {aws_account_ids = [for account_name in var.route53_resolver_forwarding_rule_shares[forwarding_rule_key].aws_account_names : module.remote_state_subaccounts.map[account_name].outputs[\"aws_account_id\"]]}... if substr(bucket_name, 0, 1) == \"l\"}}",
67+
"__is_block__": true
68+
}
69+
]
70+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"locals": [
3+
{
4+
"addition_1": "${((a + b) + c)}",
5+
"addition_2": "${a + b}",
6+
"addition_3": "${(a + b)}",
7+
"eq_before_and": "${var.env == \"prod\" && var.debug}",
8+
"and_before_ternary": "${true && true ? 1 : 0}",
9+
"mixed_arith_cmp": "${var.a + var.b * var.c > 10}",
10+
"full_chain": "${a + b == c && d || e}",
11+
"left_assoc_sub": "${a - b - c}",
12+
"left_assoc_mul_div": "${(a * b) / c}",
13+
"nested_ternary": "${(a ? b : c) ? d : e}",
14+
"unary_precedence": "${!a && b}",
15+
"neg_precedence": "${(-a) + b}",
16+
"neg_parentheses": "${-(a + b)}",
17+
"__is_block__": true
18+
}
19+
]
20+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"block": [
3+
{
4+
"label1": {
5+
"label2": {
6+
"a": 5,
7+
"b": 1256.5,
8+
"c": "${15 + (10 * 12)}",
9+
"d": "${(-a)}",
10+
"e": "${(a == b ? true : false)}",
11+
"f": "\"${\"this is a string\"}\"",
12+
"g": "${1 == 2}",
13+
"h": {
14+
"k1": 5,
15+
"k2": 10,
16+
"\"k3\"": {
17+
"k4": "\"a\""
18+
},
19+
"${(5 + 5)}": "\"d\"",
20+
"k5.attr.attr": "\"e\""
21+
},
22+
"i": [
23+
"a",
24+
"b",
25+
"\"c${aaa}\"",
26+
"d",
27+
[
28+
1,
29+
2,
30+
3
31+
],
32+
"${f(a)}",
33+
"${provider::func::aa()}"
34+
],
35+
"j": "${func(a, b, c, d)}",
36+
"k": "${a.b.5}",
37+
"l": "${a.*.b}",
38+
"m": "${a[*][c].a.*.1}",
39+
"block": [
40+
{
41+
"b1": {
42+
"a": 1,
43+
"__is_block__": true
44+
}
45+
}
46+
],
47+
"__is_block__": true
48+
}
49+
}
50+
},
51+
{
52+
"label1": {
53+
"label3": {
54+
"simple_interpolation": "\"prefix:${var}-suffix\"",
55+
"embedded_interpolation": "\"(long substring without interpolation); ${\"aaa-${local}-${local}\"}/us-west-2/key_foo\"",
56+
"deeply_nested_interpolation": "\"prefix1-${\"prefix2-${\"prefix3-$${foo:bar}\"}\"}\"",
57+
"escaped_interpolation": "\"prefix:$${aws:username}-suffix\"",
58+
"simple_and_escaped": "\"${\"bar\"}$${baz:bat}\"",
59+
"simple_and_escaped_reversed": "\"$${baz:bat}${\"bar\"}\"",
60+
"nested_escaped": "\"bar-${\"$${baz:bat}\"}\"",
61+
"__is_block__": true
62+
}
63+
}
64+
},
65+
{
66+
"route53_forwarding_rule_shares": "${{for forwarding_rule_key in keys(var.route53_resolver_forwarding_rule_shares) : \"${forwarding_rule_key}\" => {aws_account_ids = [for account_name in var.route53_resolver_forwarding_rule_shares[forwarding_rule_key].aws_account_names : module.remote_state_subaccounts.map[account_name].outputs[\"aws_account_id\"]]}... if substr(bucket_name, 0, 1) == \"l\"}}",
67+
"__is_block__": true
68+
}
69+
]
70+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"locals": [
3+
{
4+
"addition_1": "${((a + b) + c)}",
5+
"addition_2": "${a + b}",
6+
"addition_3": "${(a + b)}",
7+
"eq_before_and": "${(var.env == \"prod\") && var.debug}",
8+
"and_before_ternary": "${(true && true) ? 1 : 0}",
9+
"mixed_arith_cmp": "${(var.a + (var.b * var.c)) > 10}",
10+
"full_chain": "${(((a + b) == c) && d) || e}",
11+
"left_assoc_sub": "${(a - b) - c}",
12+
"left_assoc_mul_div": "${(a * b) / c}",
13+
"nested_ternary": "${(a ? b : c) ? d : e}",
14+
"unary_precedence": "${(!a) && b}",
15+
"neg_precedence": "${(-a) + b}",
16+
"neg_parentheses": "${-(a + b)}",
17+
"__is_block__": true
18+
}
19+
]
20+
}

0 commit comments

Comments
 (0)