diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Date/prototype/toDateString/negative-year.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Date/prototype/toDateString/negative-year.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Date/prototype/toDateString/negative-year.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/negative-year.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/negative-year.js new file mode 100644 index 0000000000..dfd228a582 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/negative-year.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Negative years must be serialized with at least four digits +esid: sec-date.prototype.todatestring +info: | + Date.prototype.toDateString ( ) + + 5. Return DateString(_t_). +---*/ + +var negative1DigitYearDateString = (new Date('-000001-07-01T00:00Z')).toDateString(); +var negative2DigitYearDateString = (new Date('-000012-07-01T00:00Z')).toDateString(); +var negative3DigitYearDateString = (new Date('-000123-07-01T00:00Z')).toDateString(); +var negative4DigitYearDateString = (new Date('-001234-07-01T00:00Z')).toDateString(); +var negative5DigitYearDateString = (new Date('-012345-07-01T00:00Z')).toDateString(); +var negative6DigitYearDateString = (new Date('-123456-07-01T00:00Z')).toDateString(); + +// Date.prototype.toDateString emits values like "Fri Mar 28 2019". +// Extract and verify just the year. +assert.sameValue(negative1DigitYearDateString.split(' ')[3], '-0001', + 'Date.prototype.toDateString serializes year -1 to "-0001"'); +assert.sameValue(negative2DigitYearDateString.split(' ')[3], '-0012', + 'Date.prototype.toDateString serializes year -12 to "-0012"'); +assert.sameValue(negative3DigitYearDateString.split(' ')[3], '-0123', + 'Date.prototype.toDateString serializes year -123 to "-0123"'); +assert.sameValue(negative4DigitYearDateString.split(' ')[3], '-1234', + 'Date.prototype.toDateString serializes year -1234 to "-1234"'); +assert.sameValue(negative5DigitYearDateString.split(' ')[3], '-12345', + 'Date.prototype.toDateString serializes year -12345 to "-12345"'); +assert.sameValue(negative6DigitYearDateString.split(' ')[3], '-123456', + 'Date.prototype.toDateString serializes year -123456 to "-123456"'); + +reportCompare(0, 0); |