From f856597503036a2bdf0b2b85c9e9819853b1beef Mon Sep 17 00:00:00 2001 From: G-Lee1031 Date: Fri, 30 Jan 2026 12:09:52 +0900 Subject: [PATCH] Added test where this value has read-only property --- .../prototype/unshift/read-only-property.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/built-ins/Array/prototype/unshift/read-only-property.js diff --git a/test/built-ins/Array/prototype/unshift/read-only-property.js b/test/built-ins/Array/prototype/unshift/read-only-property.js new file mode 100644 index 00000000000..c4ec9a9e54e --- /dev/null +++ b/test/built-ins/Array/prototype/unshift/read-only-property.js @@ -0,0 +1,24 @@ +// Copyright (C) 2026 Garham Lee. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.unshift +description: > + Array.prototype.unshift throws TypeError when a property is read-only. +info: | + Array.prototype.unshift ( ..._items_ ) + + 1. Let _O_ be ? ToObject(*this* value). + 2. Let _len_ be ? LengthOfArrayLike(_O_). + 3. Let _argCount_ be the number of elements in _items_. + 4. If _argCount_ > 0, then + a. If _len_ + _argCount_ > 253 - 1, throw a *TypeError* exception. + b. Let _k_ be _len_. + c. Repeat, while _k_ > 0, + d. Let _j_ be *+0*𝔽. + e. For each element _E_ of _items_, do + i. Perform ? Set(_O_, ! ToString(_j_), _E_, *true*). +---*/ +assert.throws(TypeError, function () { + Array.prototype.unshift.call({get 0 () {}}, 0) +}, "Array.prototype.unshift throws TypeError when a property is read-only.")