summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Object/assign/assignment-to-readonly-property-of-target-must-throw-a-typeerror-exception.js
blob: d144ee5d49ba584aaa1dd61ad0897ec3e8f08ca0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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);