tor-browser

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

setter-duplicates.js (1474B)


      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    In a class, duplicate computed property setter names produce only a single property of
      7    that name, whose value is the value of the last property of that name.
      8 ---*/
      9 var calls = 0;
     10 class C {
     11  set ['a'](_) {
     12    calls++;
     13  }
     14 }
     15 new C().a = 'A';
     16 assert.sameValue(calls, 1, "The value of `calls` is `1`, after executing `new C().a = 'A';`");
     17 
     18 calls = 0;
     19 class C2 {
     20  set b(_) {
     21    throw new Test262Error("The first `b` setter definition in `C2` is unreachable");
     22  }
     23  set ['b'](_) {
     24    calls++;
     25  }
     26 }
     27 new C2().b = 'B';
     28 assert.sameValue(calls, 1, "The value of `calls` is `1`, after executing `new C2().b = 'B';`");
     29 
     30 calls = 0;
     31 class C3 {
     32  set c(_) {
     33    throw new Test262Error("The first `c` setter definition in `C3` is unreachable");
     34  }
     35  set ['c'](_) {
     36    throw new Test262Error("The second `c` setter definition in `C3` is unreachable");
     37  }
     38  set ['c'](_) {
     39    calls++
     40  }
     41 }
     42 new C3().c = 'C';
     43 assert.sameValue(calls, 1, "The value of `calls` is `1`, after executing `new C3().c = 'C';`");
     44 
     45 calls = 0;
     46 class C4 {
     47  set ['d'](_) {
     48    throw new Test262Error("The first `d` setter definition in `C4` is unreachable");
     49  }
     50  set d(_) {
     51    calls++
     52  }
     53 }
     54 new C4().d = 'D';
     55 assert.sameValue(calls, 1, "The value of `calls` is `1`, after executing `new C4().d = 'D';`");
     56 
     57 reportCompare(0, 0);