mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
12 years ago
|
|
||
|
/*===
|
||
|
toString + parse test
|
||
|
-123456789000 -123456789000 -123456789000 -123456789000
|
||
|
-1234567000 -1234567000 -1234567000 -1234567000
|
||
|
-12345000 -12345000 -12345000 -12345000
|
||
|
-123000 -123000 -123000 -123000
|
||
|
0 0 0 0
|
||
|
0 0 0 0
|
||
|
123456789000 123456789000 123456789000 123456789000
|
||
|
1234567000 1234567000 1234567000 1234567000
|
||
|
12345000 12345000 12345000 12345000
|
||
|
123000 123000 123000 123000
|
||
|
===*/
|
||
|
|
||
|
/* Test the conversion property of E5.1 Section 15.9.4.2 (paragraph 2). */
|
||
|
|
||
|
print('toString + parse test');
|
||
|
|
||
|
function toStringParseTest() {
|
||
|
// all values have milliseconds as 0
|
||
|
var values = [
|
||
|
-123456789e3, -1234567e3, -12345e3, -123e3, -0, +0,
|
||
|
+123456789e3, +1234567e3, +12345e3, +123e3
|
||
|
];
|
||
|
var i, x;
|
||
|
|
||
|
for (i = 0; i < values.length; i++) {
|
||
|
x = new Date(values[i]);
|
||
12 years ago
|
|
||
|
// E5.1 Section 15.9.4.2, 15.9.5.2
|
||
12 years ago
|
print(x.valueOf(),
|
||
|
Date.parse(x.toString()),
|
||
|
Date.parse(x.toUTCString()),
|
||
|
Date.parse(x.toISOString()));
|
||
|
}
|
||
12 years ago
|
|
||
|
// FIXME: add more comprehensive cases
|
||
12 years ago
|
}
|
||
|
|
||
|
try {
|
||
|
toStringParseTest();
|
||
|
} catch (e) {
|
||
|
print(e.name);
|
||
|
}
|
||
|
|