33 lines
932 B
Plaintext
33 lines
932 B
Plaintext
Verify that JSON.stringify passes keys as strings when calling toJSON or the replacer function.
|
|
|
|
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
|
|
|
|
|
|
Test Replacer Function
|
|
PASS typeof globalKey is "string"
|
|
PASS globalKey is ""
|
|
PASS typeof globalValue is "object"
|
|
PASS globalValue instanceof Array is true
|
|
PASS globalValue.length is 1
|
|
PASS globalValue[0] is 42
|
|
PASS typeof globalKey is "string"
|
|
PASS globalKey is "0"
|
|
PASS typeof globalValue is "number"
|
|
PASS globalValue is 42
|
|
PASS JSON.stringify([42], replacer) is "[5]"
|
|
|
|
Test toJSON Function
|
|
PASS toJSONArrayHelperCallCounter is 0
|
|
PASS globalThis === testArray is true
|
|
PASS typeof globalKey is "string"
|
|
PASS globalKey is ""
|
|
PASS toJSONArrayHelperCallCounter is 1
|
|
PASS globalThis === testObject is true
|
|
PASS typeof globalKey is "string"
|
|
PASS globalKey is "0"
|
|
PASS JSON.stringify(testArray) is "[true]"
|
|
PASS successfullyParsed is true
|
|
|
|
TEST COMPLETE
|
|
|