tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

setter-super.js (1032B)


      1 // Copyright (C) 2014 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 es6id: 12.2.5
      5 description: >
      6    computed property setters can call super methods
      7 ---*/
      8 
      9 function ID(x) {
     10  return x;
     11 }
     12 
     13 var value;
     14 var proto = {
     15  m(name, v) {
     16    value = name + ' ' + v;
     17  }
     18 };
     19 var object = {
     20  set ['a'](v) { super.m('a', v); },
     21  set [ID('b')](v) { super.m('b', v); },
     22  set [0](v) { super.m('0', v); },
     23  set [ID(1)](v) { super.m('1', v); },
     24 };
     25 
     26 Object.setPrototypeOf(object, proto);
     27 
     28 object.a = 2;
     29 assert.sameValue(value, 'a 2', "The value of `value` is `'a 2'`, after executing `object.a = 2;`");
     30 object.b = 3;
     31 assert.sameValue(value, 'b 3', "The value of `value` is `'b 3'`, after executing `object.b = 3;`");
     32 object[0] = 4;
     33 assert.sameValue(value, '0 4', "The value of `value` is `'0 4'`, after executing `object[0] = 4;`");
     34 object[1] = 5;
     35 assert.sameValue(value, '1 5', "The value of `value` is `'1 5'`, after executing `object[1] = 5;`");
     36 
     37 reportCompare(0, 0);