diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Date/S15.9.2.1_A2.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Date/S15.9.2.1_A2.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Date/S15.9.2.1_A2.js | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Date/S15.9.2.1_A2.js b/js/src/tests/test262/built-ins/Date/S15.9.2.1_A2.js new file mode 100644 index 0000000000..81b6bfc777 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.2.1_A2.js @@ -0,0 +1,94 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date-year-month-date-hours-minutes-seconds-ms +info: | + All of the arguments are optional, any arguments supplied are + accepted but are completely ignored. A string is created and returned as + if by the expression (new Date()).toString() +es5id: 15.9.2.1_A2 +description: Use various number arguments and various types of ones +---*/ + +function isEqual(d1, d2) { + if (d1 === d2) { + return true; + } else if (Math.abs(Date.parse(d1) - Date.parse(d2)) <= 1000) { + return true; + } else { + return false; + } +} + +assert( + isEqual(Date(), (new Date()).toString()), + 'isEqual(Date(), (new Date()).toString()) must return true' +); + +assert( + isEqual(Date(1), (new Date()).toString()), + 'isEqual(Date(1), (new Date()).toString()) must return true' +); + +assert( + isEqual(Date(1970, 1), (new Date()).toString()), + 'isEqual(Date(1970, 1), (new Date()).toString()) must return true' +); + +assert( + isEqual(Date(1970, 1, 1), (new Date()).toString()), + 'isEqual(Date(1970, 1, 1), (new Date()).toString()) must return true' +); + +assert( + isEqual(Date(1970, 1, 1, 1), (new Date()).toString()), + 'isEqual(Date(1970, 1, 1, 1), (new Date()).toString()) must return true' +); + +assert( + isEqual(Date(1970, 1, 1, 1), (new Date()).toString()), + 'isEqual(Date(1970, 1, 1, 1), (new Date()).toString()) must return true' +); + +assert( + isEqual(Date(1970, 1, 1, 1, 0), (new Date()).toString()), + 'isEqual(Date(1970, 1, 1, 1, 0), (new Date()).toString()) must return true' +); + +assert( + isEqual(Date(1970, 1, 1, 1, 0, 0), (new Date()).toString()), + 'isEqual(Date(1970, 1, 1, 1, 0, 0), (new Date()).toString()) must return true' +); + +assert( + isEqual(Date(1970, 1, 1, 1, 0, 0, 0), (new Date()).toString()), + 'isEqual(Date(1970, 1, 1, 1, 0, 0, 0), (new Date()).toString()) must return true' +); + +assert( + isEqual(Date(Number.NaN), (new Date()).toString()), + 'isEqual(Date(Number.NaN), (new Date()).toString()) must return true' +); + +assert( + isEqual(Date(Number.POSITIVE_INFINITY), (new Date()).toString()), + 'isEqual(Date(Number.POSITIVE_INFINITY), (new Date()).toString()) must return true' +); + +assert( + isEqual(Date(Number.NEGATIVE_INFINITY), (new Date()).toString()), + 'isEqual(Date(Number.NEGATIVE_INFINITY), (new Date()).toString()) must return true' +); + +assert( + isEqual(Date(undefined), (new Date()).toString()), + 'isEqual(Date(undefined), (new Date()).toString()) must return true' +); + +assert( + isEqual(Date(null), (new Date()).toString()), + 'isEqual(Date(null), (new Date()).toString()) must return true' +); + +reportCompare(0, 0); |