Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for various expressions (#683)
- Loading branch information
Showing
2 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
output "null_out" { | ||
value = null | ||
} | ||
|
||
output "number_out" { | ||
value = 0 | ||
} | ||
|
||
output "bool_out" { | ||
value = true | ||
} | ||
|
||
output "string_out" { | ||
value = "hello world" | ||
} | ||
|
||
output "tuple_out" { | ||
value = [1, 2, 3] | ||
} | ||
|
||
output "str_object_out" { | ||
value = { | ||
hello: "hallo" | ||
goodbye: "ha det" | ||
} | ||
} | ||
|
||
locals { | ||
a_key = "hello" | ||
a_value = -1 | ||
} | ||
|
||
output "complex_object_out" { | ||
value = { | ||
a_tuple: ["a", "b", "c"] | ||
an_object: { | ||
literal_key: 1 | ||
another_literal_key = 2 | ||
"yet_another_literal_key": local.a_value | ||
# This doesn't translate correctly | ||
# (local.a_key) = 4 | ||
} | ||
ambiguous_for: { | ||
"for" = 1 | ||
} | ||
} | ||
} | ||
|
||
output "quoted_template" { | ||
value = "The key is ${local.a_key}" | ||
} | ||
|
||
output "heredoc" { | ||
value = <<END | ||
This is also a template. | ||
So we can output the key again ${local.a_key} | ||
END | ||
} | ||
|
||
output "for_tuple" { | ||
value = [for key, value in ["a", "b"] : "${key}:${value}:${local.a_value}" if key != 0] | ||
} | ||
|
||
output "for_tuple_value_only" { | ||
value = [for value in ["a", "b"] : "${value}:${local.a_value}"] | ||
} | ||
|
||
output "for_object" { | ||
value = {for key, value in ["a", "b"] : key => "${value}:${local.a_value}" if key != 0} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
output nullOut { | ||
value = null | ||
} | ||
output numberOut { | ||
value = 0 | ||
} | ||
output boolOut { | ||
value = true | ||
} | ||
output stringOut { | ||
value = "hello world" | ||
} | ||
output tupleOut { | ||
value = [1, 2, 3] | ||
} | ||
output strObjectOut { | ||
value = { | ||
hello: "hallo" | ||
goodbye: "ha det" | ||
} | ||
} | ||
aKey = "hello" | ||
aValue = -1 | ||
output complexObjectOut { | ||
value = { | ||
a_tuple: ["a", "b", "c"] | ||
an_object: { | ||
literal_key: 1 | ||
another_literal_key = 2 | ||
"yet_another_literal_key": aValue | ||
# This doesn't translate correctly | ||
# (local.a_key) = 4 | ||
} | ||
ambiguous_for: { | ||
"for" = 1 | ||
} | ||
} | ||
} | ||
output quotedTemplate { | ||
value = "The key is ${aKey}" | ||
} | ||
output heredoc { | ||
value = <<END | ||
This is also a template. | ||
So we can output the key again ${aKey} | ||
END | ||
} | ||
output forTuple { | ||
value = [for key, value in ["a", "b"] : "${key}:${value}:${aValue}" if key != 0] | ||
} | ||
output forTupleValueOnly { | ||
value = [for value in ["a", "b"] : "${value}:${aValue}"] | ||
} | ||
output forObject { | ||
value = {for key, value in ["a", "b"] : key => "${value}:${aValue}" if key != 0} | ||
} |