Make Date methods argument coercion spec compliant (#104)

This commit is contained in:
Ben Noordhuis 2023-11-21 15:04:38 +01:00 committed by GitHub
parent 7aabea9db0
commit 7c9cf46f97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 37 deletions

View file

@ -45895,20 +45895,20 @@ static JSValue set_date_field(JSContext *ctx, JSValueConst this_val,
res = get_date_fields(ctx, this_val, fields, is_local, first_field == 0); res = get_date_fields(ctx, this_val, fields, is_local, first_field == 0);
if (res < 0) if (res < 0)
return JS_EXCEPTION; return JS_EXCEPTION;
if (res && argc > 0) {
n = end_field - first_field; // Argument coercion is observable and must be done unconditionally.
if (argc < n) n = min_int(argc, end_field - first_field);
n = argc; for(i = 0; i < n; i++) {
for(i = 0; i < n; i++) { if (JS_ToFloat64(ctx, &a, argv[i]))
if (JS_ToFloat64(ctx, &a, argv[i])) return JS_EXCEPTION;
return JS_EXCEPTION; if (!isfinite(a))
if (!isfinite(a)) res = FALSE;
goto done; fields[first_field + i] = trunc(a);
fields[first_field + i] = trunc(a);
}
d = set_date_fields(fields, is_local);
} }
done:
if (res && argc > 0)
d = set_date_fields(fields, is_local);
return JS_SetThisTimeValue(ctx, this_val, d); return JS_SetThisTimeValue(ctx, this_val, d);
} }

View file

@ -5,30 +5,6 @@ test262/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedStart-brok
test262/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedStart-broken-promise.js:34: strict mode: TypeError: $DONE() not called test262/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedStart-broken-promise.js:34: strict mode: TypeError: $DONE() not called
test262/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-broken-promise-try-catch.js:39: TypeError: $DONE() not called test262/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-broken-promise-try-catch.js:39: TypeError: $DONE() not called
test262/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-broken-promise-try-catch.js:39: strict mode: TypeError: $DONE() not called test262/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-broken-promise-try-catch.js:39: strict mode: TypeError: $DONE() not called
test262/test/built-ins/Date/prototype/setDate/arg-coercion-order.js:28: Test262Error: ToNumber invoked exactly once Expected SameValue(«0», «1») to be true
test262/test/built-ins/Date/prototype/setDate/arg-coercion-order.js:28: strict mode: Test262Error: ToNumber invoked exactly once Expected SameValue(«0», «1») to be true
test262/test/built-ins/Date/prototype/setHours/arg-coercion-order.js:57: Test262Error: Expected [] and [valueOf hour, valueOf min, valueOf sec, valueOf ms] to have the same contents.
test262/test/built-ins/Date/prototype/setHours/arg-coercion-order.js:57: strict mode: Test262Error: Expected [] and [valueOf hour, valueOf min, valueOf sec, valueOf ms] to have the same contents.
test262/test/built-ins/Date/prototype/setMilliseconds/arg-coercion-order.js:28: Test262Error: ToNumber invoked exactly once Expected SameValue(«0», «1») to be true
test262/test/built-ins/Date/prototype/setMilliseconds/arg-coercion-order.js:28: strict mode: Test262Error: ToNumber invoked exactly once Expected SameValue(«0», «1») to be true
test262/test/built-ins/Date/prototype/setMinutes/arg-coercion-order.js:49: Test262Error: Expected [] and [valueOf min, valueOf sec, valueOf ms] to have the same contents.
test262/test/built-ins/Date/prototype/setMinutes/arg-coercion-order.js:49: strict mode: Test262Error: Expected [] and [valueOf min, valueOf sec, valueOf ms] to have the same contents.
test262/test/built-ins/Date/prototype/setMonth/arg-coercion-order.js:41: Test262Error: Expected [] and [valueOf month, valueOf date] to have the same contents.
test262/test/built-ins/Date/prototype/setMonth/arg-coercion-order.js:41: strict mode: Test262Error: Expected [] and [valueOf month, valueOf date] to have the same contents.
test262/test/built-ins/Date/prototype/setSeconds/arg-coercion-order.js:41: Test262Error: Expected [] and [valueOf sec, valueOf ms] to have the same contents.
test262/test/built-ins/Date/prototype/setSeconds/arg-coercion-order.js:41: strict mode: Test262Error: Expected [] and [valueOf sec, valueOf ms] to have the same contents.
test262/test/built-ins/Date/prototype/setUTCDate/arg-coercion-order.js:25: Test262Error: ToNumber invoked exactly once Expected SameValue(«0», «1») to be true
test262/test/built-ins/Date/prototype/setUTCDate/arg-coercion-order.js:25: strict mode: Test262Error: ToNumber invoked exactly once Expected SameValue(«0», «1») to be true
test262/test/built-ins/Date/prototype/setUTCHours/arg-coercion-order.js:50: Test262Error: Expected [] and [valueOf hour, valueOf min, valueOf sec, valueOf ms] to have the same contents.
test262/test/built-ins/Date/prototype/setUTCHours/arg-coercion-order.js:50: strict mode: Test262Error: Expected [] and [valueOf hour, valueOf min, valueOf sec, valueOf ms] to have the same contents.
test262/test/built-ins/Date/prototype/setUTCMilliseconds/arg-coercion-order.js:26: Test262Error: ToNumber invoked exactly once Expected SameValue(«0», «1») to be true
test262/test/built-ins/Date/prototype/setUTCMilliseconds/arg-coercion-order.js:26: strict mode: Test262Error: ToNumber invoked exactly once Expected SameValue(«0», «1») to be true
test262/test/built-ins/Date/prototype/setUTCMinutes/arg-coercion-order.js:42: Test262Error: Expected [] and [valueOf min, valueOf sec, valueOf ms] to have the same contents.
test262/test/built-ins/Date/prototype/setUTCMinutes/arg-coercion-order.js:42: strict mode: Test262Error: Expected [] and [valueOf min, valueOf sec, valueOf ms] to have the same contents.
test262/test/built-ins/Date/prototype/setUTCMonth/arg-coercion-order.js:34: Test262Error: Expected [] and [valueOf month, valueOf date] to have the same contents.
test262/test/built-ins/Date/prototype/setUTCMonth/arg-coercion-order.js:34: strict mode: Test262Error: Expected [] and [valueOf month, valueOf date] to have the same contents.
test262/test/built-ins/Date/prototype/setUTCSeconds/arg-coercion-order.js:34: Test262Error: Expected [] and [valueOf sec, valueOf ms] to have the same contents.
test262/test/built-ins/Date/prototype/setUTCSeconds/arg-coercion-order.js:34: strict mode: Test262Error: Expected [] and [valueOf sec, valueOf ms] to have the same contents.
test262/test/built-ins/Function/internals/Construct/derived-this-uninitialized-realm.js:20: Test262Error: Expected a ReferenceError but got a different error constructor with the same name test262/test/built-ins/Function/internals/Construct/derived-this-uninitialized-realm.js:20: Test262Error: Expected a ReferenceError but got a different error constructor with the same name
test262/test/built-ins/Function/internals/Construct/derived-this-uninitialized-realm.js:20: strict mode: Test262Error: Expected a ReferenceError but got a different error constructor with the same name test262/test/built-ins/Function/internals/Construct/derived-this-uninitialized-realm.js:20: strict mode: Test262Error: Expected a ReferenceError but got a different error constructor with the same name
test262/test/built-ins/RegExp/lookahead-quantifier-match-groups.js:27: Test262Error: Expected [a, abc] and [a, undefined] to have the same contents. ? quantifier test262/test/built-ins/RegExp/lookahead-quantifier-match-groups.js:27: Test262Error: Expected [a, abc] and [a, undefined] to have the same contents. ? quantifier