Skip to content

Commit

Permalink
Write "inf" instead of "Inf" in JSON tests
Browse files Browse the repository at this point in the history
Doesn't really matter for the toml-test test runner, but we use
toml-test-decoder for generating tests, and "Inf" with capital was
causing issues for some: toml-lang/toml-test#143
  • Loading branch information
arp242 committed Oct 10, 2023
1 parent 4f8abaa commit c0a26cb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions internal/tag/add.go
Expand Up @@ -60,11 +60,16 @@ func Add(key string, tomlData any) any {
case int64:
return tag("integer", fmt.Sprintf("%d", orig))
case float64:
// Special case for nan since NaN == NaN is false.
if math.IsNaN(orig) {
switch {
case math.IsNaN(orig):
return tag("float", "nan")
case math.IsInf(orig, 1):
return tag("float", "inf")
case math.IsInf(orig, -1):
return tag("float", "-inf")
default:
return tag("float", fmt.Sprintf("%v", orig))
}
return tag("float", fmt.Sprintf("%v", orig))
}
}

Expand Down

0 comments on commit c0a26cb

Please sign in to comment.