mirror of
https://github.com/apple/pkl.git
synced 2026-05-28 01:29:15 +02:00
YamlRenderer: allow all primitive scalar types as map keys (#879)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// Test that non-String scalars can be rendered as YAML map keys.
|
||||
mappingInt = new Mapping {
|
||||
[5] = "abc"
|
||||
[10] = "def"
|
||||
[20] = "ghi"
|
||||
}
|
||||
|
||||
mapInt = mappingInt.toMap()
|
||||
|
||||
mappingFloat = new Mapping {
|
||||
[5.0] = "abc"
|
||||
[10.5] = "def"
|
||||
[20.999999990] = "ghi"
|
||||
}
|
||||
|
||||
mapFloat = mappingFloat.toMap()
|
||||
|
||||
mappingBool = new Mapping {
|
||||
[true] = "abc"
|
||||
[false] = "def"
|
||||
}
|
||||
|
||||
mapBool = mappingBool.toMap()
|
||||
|
||||
mappingNull = new Mapping {
|
||||
[null] = "abc"
|
||||
}
|
||||
|
||||
mapNull = mappingNull.toMap()
|
||||
|
||||
output {
|
||||
renderer = new YamlRenderer {}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
mappingInt:
|
||||
5: abc
|
||||
10: def
|
||||
20: ghi
|
||||
mapInt:
|
||||
5: abc
|
||||
10: def
|
||||
20: ghi
|
||||
mappingFloat:
|
||||
5.0: abc
|
||||
10.5: def
|
||||
20.99999999: ghi
|
||||
mapFloat:
|
||||
5.0: abc
|
||||
10.5: def
|
||||
20.99999999: ghi
|
||||
mappingBool:
|
||||
true: abc
|
||||
false: def
|
||||
mapBool:
|
||||
true: abc
|
||||
false: def
|
||||
mappingNull:
|
||||
null: abc
|
||||
mapNull:
|
||||
null: abc
|
||||
Reference in New Issue
Block a user