Verify that Duration#with() doesn't accept duration strings

Also fix the description and put the string tests together.
This commit is contained in:
Ms2ger 2025-07-02 12:25:00 +02:00 committed by Philip Chimento
parent 749a6f9509
commit 68a817d713

View File

@ -3,7 +3,7 @@
/*---
esid: sec-temporal.duration.prototype.with
description: Passing a primitive other than string to with() throws
description: Passing a primitive to with() throws
features: [Symbol, Temporal]
---*/
@ -12,7 +12,8 @@ assert.throws(TypeError, () => instance.with(undefined), "undefined");
assert.throws(TypeError, () => instance.with(null), "null");
assert.throws(TypeError, () => instance.with(true), "boolean");
assert.throws(TypeError, () => instance.with(""), "empty string");
assert.throws(TypeError, () => instance.with("P1D"), "duration string");
assert.throws(TypeError, () => instance.with("string"), "string");
assert.throws(TypeError, () => instance.with(Symbol()), "Symbol");
assert.throws(TypeError, () => instance.with(7), "number");
assert.throws(TypeError, () => instance.with(7n), "bigint");
assert.throws(TypeError, () => instance.with("string"), "string");