-
Notifications
You must be signed in to change notification settings - Fork 660
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly serialize negative numbers
This commit fixes a bug where negative numbers were not correctly serialized, because the value parser confused "references" (which is where special negative tokens for special values exist), and "values" (where negative numbers are just negative numbers). The parser now correctly distinguishes between the two.
- Loading branch information
1 parent
65d61bd
commit 34bd028
Showing
8 changed files
with
208 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
export const snapshot = {}; | ||
|
||
snapshot[`round trip - undefined 1`] = `"-1"`; | ||
|
||
snapshot[`round trip - null 1`] = `"-2"`; | ||
|
||
snapshot[`round trip - 1 1`] = `"[1]"`; | ||
|
||
snapshot[`round trip - 2 1`] = `"[2]"`; | ||
|
||
snapshot[`round trip - -2 1`] = `"[-2]"`; | ||
|
||
snapshot[`round trip - Infinity 1`] = `"-4"`; | ||
|
||
snapshot[`round trip - -Infinity 1`] = `"-5"`; | ||
|
||
snapshot[`round trip - 0 1`] = `"[0]"`; | ||
|
||
snapshot[`round trip - -0 1`] = `"-6"`; | ||
|
||
snapshot[`round trip - NaN 1`] = `"-3"`; | ||
|
||
snapshot[`round trip - 0 2`] = `"[0]"`; | ||
|
||
snapshot[`round trip - true 1`] = `"[true]"`; | ||
|
||
snapshot[`round trip - false 1`] = `"[false]"`; | ||
|
||
snapshot[`round trip - 'abc' 1`] = `'["abc"]'`; | ||
|
||
snapshot[`round trip - 1n 1`] = `'[["BigInt","1"]]'`; | ||
|
||
snapshot[`round trip - -1n 1`] = `'[["BigInt","-1"]]'`; | ||
|
||
snapshot[`round trip - [ 1, 2, 3 ] 1`] = `"[[1,2,3],1,2,3]"`; | ||
|
||
snapshot[`round trip - [ null, undefined, -2 ] 1`] = `"[[-2,-1,1],-2]"`; | ||
|
||
snapshot[`round trip - { a: 1, b: null, c: -2 } 1`] = `'[{"a":1,"b":-2,"c":2},1,-2]'`; | ||
|
||
snapshot[`round trip - Uint8Array(3) [ 1, 2, 3 ] 1`] = `'[["Uint8Array","AQID"]]'`; | ||
|
||
snapshot[`round trip - 1990-05-31T00:00:00.000Z 1`] = `'[["Date","1990-05-31T00:00:00.000Z"]]'`; | ||
|
||
snapshot[`round trip - Map(2) { 1 => null, undefined => -2 } 1`] = `'[["Map",[1,-2,-1,2]],1,-2]'`; | ||
|
||
snapshot[`round trip - Set(5) { 1, 2, null, -2, NaN } 1`] = `'[["Set",[1,2,-2,3,-3]],1,2,-2]'`; | ||
|
||
snapshot[`round trip - [ 1, <1 empty item>, 3 ] 1`] = `"[[1,-7,2],1,3]"`; | ||
|
||
snapshot[`round trip - /foo["]/ 1`] = `'[["RegExp","foo[\\\\"]", ""]]'`; | ||
|
||
snapshot[`round trip - { a: { foo: 123 }, b: [ { foo: 123 }, { foo: 123 } ] } 1`] = `'[{"a":1,"b":3},{"foo":2},123,[1,1]]'`; | ||
|
||
snapshot[`round trip - <ref *1> { a: 1, b: [Circular *1] } 1`] = `'[{"a":1,"b":0},1]'`; |
Oops, something went wrong.