From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../Date/prototype/setMonth/arg-coercion-order.js | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-coercion-order.js (limited to 'js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-coercion-order.js') diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-coercion-order.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-coercion-order.js new file mode 100644 index 0000000000..a1bc3862af --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-coercion-order.js @@ -0,0 +1,43 @@ +// Copyright (C) 2021 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmonth +description: Order of coercion of provided argument vs NaN check +info: | + 1. Let t be ? thisTimeValue(this value). + 2. Let m be ? ToNumber(month). + 3. If date is present, let dt be ? ToNumber(date). + 4. If t is NaN, return NaN. + 5. Set t to LocalTime(t). + 6. If date is not present, let dt be DateFromTime(t). + 7. Let newDate be MakeDate(MakeDay(YearFromTime(t), m, dt), TimeWithinDay(t)). + 8. Let u be TimeClip(UTC(newDate)). + 9. Set the [[DateValue]] internal slot of this Date object to u. + 10. Return u. +includes: [compareArray.js] +---*/ + +var date = new Date(NaN); +var effects = []; +var argMonth = { + valueOf: function() { + effects.push('valueOf month'); + return 0; + } +}; +var argDate = { + valueOf: function() { + effects.push('valueOf date'); + return 0; + } +}; + +var returnValue = date.setMonth(argMonth, argDate); + +var expectedEffects = ['valueOf month', 'valueOf date']; + +assert.compareArray(effects, expectedEffects); +assert.sameValue(returnValue, NaN, 'argument is ignored when `this` is an invalid date'); +assert.sameValue(date.getTime(), NaN, 'argument is ignored when `this` is an invalid date'); + +reportCompare(0, 0); -- cgit v1.2.3