tor-browser

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

numbers-class.js (1581B)


      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    to name, accessor side effects numbers 2
      7 includes: [compareArray.js]
      8 ---*/
      9 var counter = 0;
     10 var key1vof = [];
     11 var key2vof = [];
     12 var key1 = {
     13  valueOf: function() {
     14    key1vof.push(counter);
     15    counter += 1;
     16    return 1;
     17  },
     18  toString: null
     19 };
     20 var key2 = {
     21  valueOf: function() {
     22    key2vof.push(counter);
     23    counter += 1;
     24    return 2;
     25  },
     26  toString: null
     27 };
     28 
     29 class C {
     30  a() { return 'A'; }
     31  [key1]() { return 'B'; }
     32  c() { return 'C'; }
     33  [key2]() { return 'D'; }
     34 }
     35 
     36 assert.compareArray(key1vof, [0], "order set for key1");
     37 assert.compareArray(key2vof, [1], "order set for key2");
     38 
     39 assert.sameValue(counter, 2, "The value of `counter` is `2`");
     40 assert.sameValue(new C().a(), 'A', "`new C().a()` returns `'A'`. Defined as `a() { return 'A'; }`");
     41 assert.sameValue(new C()[1](), 'B', "`new C()[1]()` returns `'B'`. Defined as `[key1]() { return 'B'; }`");
     42 assert.sameValue(new C().c(), 'C', "`new C().c()` returns `'C'`. Defined as `c() { return 'C'; }`");
     43 assert.sameValue(new C()[2](), 'D', "`new C()[2]()` returns `'D'`. Defined as `[key2]() { return 'D'; }`");
     44 assert.sameValue(Object.keys(C.prototype).length, 0, "No enum keys from C.prototype");
     45 assert(
     46  compareArray(Object.getOwnPropertyNames(C.prototype), ['1', '2', 'constructor', 'a', 'c']),
     47  "`compareArray(Object.getOwnPropertyNames(C.prototype), ['1', '2', 'constructor', 'a', 'c'])` returns `true`"
     48 );
     49 
     50 reportCompare(0, 0);