Skip to content

Commit

Permalink
Merge c075b18 into ad0c04b
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Jan 11, 2021
2 parents ad0c04b + c075b18 commit 859e42d
Show file tree
Hide file tree
Showing 6 changed files with 1,865 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const INFINITY: TagResolver<number> = {
tag: "tag:yaml.org,2002:float",
test(str) {
// see https://yaml.org/spec/1.2/spec.html#id2805071
return /^[-+]?(\.inf |\.Inf|\.INF)$/u.test(str)
return /^[-+]?(\.inf|\.Inf|\.INF)$/u.test(str)
},
resolve(str) {
return str.startsWith("-") ? -Infinity : Infinity
Expand All @@ -105,7 +105,7 @@ export const NAN: TagResolver<number> = {
tag: "tag:yaml.org,2002:float",
test(str) {
// see https://yaml.org/spec/1.2/spec.html#id2805071
return str === "NaN" || str === "nan" || str === "NAN"
return str === ".NaN" || str === ".nan" || str === ".NAN"
},
resolve() {
return NaN
Expand Down
7 changes: 7 additions & 0 deletions tests/fixtures/parser/ast/types01-input.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
A null: null
Also a null: # Empty
Not a null: ""
Booleans: [ true, True, false, FALSE ]
Integers: [ 0, 0o7, 0x3A, -19 ]
Floats: [ 0., -0.0, .5, +12e03, -2E+05 ]
Also floats: [ .inf, -.Inf, +.INF, .NAN ]
Loading

0 comments on commit 859e42d

Please sign in to comment.