specsuite: tests for primitive type literals
This commit is contained in:
parent
791068cd07
commit
48fbad7bf4
17
specsuite/tests/expressions/primitive_literals.hcl
Normal file
17
specsuite/tests/expressions/primitive_literals.hcl
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Numbers
|
||||||
|
whole_number = 5
|
||||||
|
fractional_number = 3.2
|
||||||
|
fractional_number_precision = 3.14159265358979323846264338327950288419716939937510582097494459
|
||||||
|
|
||||||
|
# Strings
|
||||||
|
string_ascii = "hello"
|
||||||
|
string_unicode_bmp = "ЖЖ"
|
||||||
|
string_unicode_astral = "👩👩👧👦"
|
||||||
|
string_unicode_nonnorm = "años" # This is intentionally a combining tilde followed by n
|
||||||
|
|
||||||
|
# Booleans
|
||||||
|
true = true
|
||||||
|
false = false
|
||||||
|
|
||||||
|
# Null
|
||||||
|
null = null
|
12
specsuite/tests/expressions/primitive_literals.hcldec
Normal file
12
specsuite/tests/expressions/primitive_literals.hcldec
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
object {
|
||||||
|
attr "whole_number" { type = any }
|
||||||
|
attr "fractional_number" { type = any }
|
||||||
|
attr "fractional_number_precision" { type = any }
|
||||||
|
attr "string_ascii" { type = any }
|
||||||
|
attr "string_unicode_bmp" { type = any }
|
||||||
|
attr "string_unicode_astral" { type = any }
|
||||||
|
attr "string_unicode_nonnorm" { type = any }
|
||||||
|
attr "true" { type = any }
|
||||||
|
attr "false" { type = any }
|
||||||
|
attr "null" { type = any }
|
||||||
|
}
|
34
specsuite/tests/expressions/primitive_literals.t
Normal file
34
specsuite/tests/expressions/primitive_literals.t
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
result_type = object({
|
||||||
|
whole_number = number
|
||||||
|
fractional_number = number
|
||||||
|
fractional_number_precision = number
|
||||||
|
string_ascii = string
|
||||||
|
string_unicode_bmp = string
|
||||||
|
string_unicode_astral = string
|
||||||
|
string_unicode_nonnorm = string
|
||||||
|
true = bool
|
||||||
|
false = bool
|
||||||
|
null = any
|
||||||
|
})
|
||||||
|
result = {
|
||||||
|
# Numbers
|
||||||
|
whole_number = 5
|
||||||
|
fractional_number = 3.2
|
||||||
|
fractional_number_precision = 3.14159265358979323846264338327950288419716939937510582097494459
|
||||||
|
|
||||||
|
# Strings
|
||||||
|
string_ascii = "hello"
|
||||||
|
string_unicode_bmp = "ЖЖ"
|
||||||
|
string_unicode_astral = "👩👩👧👦"
|
||||||
|
string_unicode_nonnorm = "años" # now a precomposed ñ, because HCL imposes NFC normalization
|
||||||
|
# FIXME: The above normalization test doesn't necessarily test what it thinks
|
||||||
|
# it is testing, because this file is also HCL and thus subject to
|
||||||
|
# normalization; as long as the parser normalizes consistently this could
|
||||||
|
# pass even if it's using a different normalization form.
|
||||||
|
|
||||||
|
# The left hand side of these are quoted to make it clear that we're expecting
|
||||||
|
# to get strings here, not really true/false/null.
|
||||||
|
"true" = true
|
||||||
|
"false" = false
|
||||||
|
"null" = null
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user