Skip to content
This repository was archived by the owner on May 28, 2019. It is now read-only.

Commit 139d1eb

Browse files
author
Kit Cambridge
committed
The date serialization tests should not be MDT-specific. Closes #3.
1 parent 2cd484f commit 139d1eb

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

Diff for: README.md

-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ JSON 3 has been **tested** with the following web browsers, CommonJS environment
8484

8585
* Attempting to serialize the `arguments` object may produce inconsistent results due to specification and environment differences. As a workaround, please convert the `arguments` object to an array first: `JSON.stringify([].slice.call(arguments))`.
8686

87-
* The four date serialization unit tests may fail if the system clock is set incorrectly.
88-
8987
### Required Native Methods
9088

9189
JSON 3 assumes that the following methods exist and function as described in the ECMAScript specification:

Diff for: test/test_json3.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@
221221
});
222222

223223
testSuite.addTest("`stringify`", function () {
224-
var expected = 20, value;
224+
var expected = 20, value, pattern;
225225

226226
this.serializes("null", null, "`null` is represented literally");
227227
this.serializes("null", 1 / 0, "`Infinity` is serialized as `null`");
@@ -251,11 +251,9 @@
251251
value[5] = 1;
252252
this.serializes("[null,null,null,null,null,1]", value, "Sparse arrays should serialize correctly");
253253

254-
value = new Date(1994, 6, 3);
255-
this.serializes('"1994-07-03T06:00:00.000Z"', value, "Dates are serialized using the simplified date time string format");
256-
257-
value = new Date(1993, 5, 2, 2, 10, 28, 224);
258-
this.serializes('"1993-06-02T08:10:28.224Z"', value, "The date time string should conform to the format outlined in the spec");
254+
pattern = /^"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z"$/;
255+
this.ok(pattern.test(JSON.stringify(new Date(1994, 6, 3))), "Dates are serialized using the simplified date time string format");
256+
this.ok(pattern.test(JSON.stringify(new Date(1993, 5, 2, 2, 10, 28, 224))), "The date time string should conform to the format outlined in the spec");
259257

260258
// Safari 2 restricts date time values to the range `[(-2 ** 31),
261259
// (2 ** 31) - 1]`, which respectively correspond to the minimum and

0 commit comments

Comments
 (0)