diff options
Diffstat (limited to '')
-rw-r--r-- | js/src/tests/test262/built-ins/Object/assign/assignment-to-readonly-property-of-target-must-throw-a-typeerror-exception.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Object/assign/assignment-to-readonly-property-of-target-must-throw-a-typeerror-exception.js b/js/src/tests/test262/built-ins/Object/assign/assignment-to-readonly-property-of-target-must-throw-a-typeerror-exception.js new file mode 100644 index 0000000000..d144ee5d49 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/assign/assignment-to-readonly-property-of-target-must-throw-a-typeerror-exception.js @@ -0,0 +1,31 @@ +// Copyright 2020 Rick Waldron. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-object.assign +description: > + Assignment to readonly property of target must throw a TypeError exception +info: | + Let to be ? ToObject(target). + If only one argument was passed, return to. + For each element nextSource of sources, do + If nextSource is neither undefined nor null, then + Let from be ! ToObject(nextSource). + Let keys be ? from.[[OwnPropertyKeys]](). + For each element nextKey of keys, do + Let desc be ? from.[[GetOwnProperty]](nextKey). + If desc is not undefined and desc.[[Enumerable]] is true, then + Let propValue be ? Get(from, nextKey). + Perform ? Set(to, nextKey, propValue, true). + + Set ( O, P, V, Throw ) sec-set-o-p-v-throw + + Let success be ? O.[[Set]](P, V, O). + If success is false and Throw is true, throw a TypeError exception. +---*/ + +assert.throws(TypeError, () => { + Object.assign('a', [1]); +}); + +reportCompare(0, 0); |