mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-10 08:35:42 +00:00
encoder_lua: Handle explicitly positive infinity
This commit is contained in:
parent
610896e5ed
commit
8f6d57f58e
@ -129,6 +129,8 @@ numbers:
|
||||
- octal: 0o30
|
||||
- float: 123.45
|
||||
- infinity: .inf
|
||||
plus_infinity: +.inf
|
||||
minus_infinity: -.inf
|
||||
- not: .nan
|
||||
|
||||
```
|
||||
@ -162,6 +164,8 @@ return {
|
||||
},
|
||||
{
|
||||
["infinity"] = (1/0);
|
||||
["plus_infinity"] = (1/0);
|
||||
["minus_infinity"] = (-1/0);
|
||||
},
|
||||
{
|
||||
["not"] = (0/0);
|
||||
|
||||
@ -292,7 +292,7 @@ func (le *luaEncoder) encodeAny(writer io.Writer, node *yaml.Node) error {
|
||||
return writeString(writer, strings.ToLower(node.Value))
|
||||
case "!!float":
|
||||
switch strings.ToLower(node.Value) {
|
||||
case ".inf":
|
||||
case ".inf", "+.inf":
|
||||
return writeString(writer, "(1/0)")
|
||||
case "-.inf":
|
||||
return writeString(writer, "(-1/0)")
|
||||
|
||||
@ -135,6 +135,8 @@ numbers:
|
||||
- octal: 0o30
|
||||
- float: 123.45
|
||||
- infinity: .inf
|
||||
plus_infinity: +.inf
|
||||
minus_infinity: -.inf
|
||||
- not: .nan
|
||||
`,
|
||||
expected: `return {
|
||||
@ -161,6 +163,8 @@ numbers:
|
||||
},
|
||||
{
|
||||
["infinity"] = (1/0);
|
||||
["plus_infinity"] = (1/0);
|
||||
["minus_infinity"] = (-1/0);
|
||||
},
|
||||
{
|
||||
["not"] = (0/0);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user