tor-browser

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

numbers-object.js (1166B)


      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 side effects numbers
      7 includes: [compareArray.js]
      8 ---*/
      9 var counter = 0;
     10 var key1 = {
     11  valueOf: function() {
     12    assert.sameValue(counter++, 0, "The result of `counter++` is `0`");
     13    return 1;
     14  },
     15  toString: null
     16 };
     17 var key2 = {
     18  valueOf: function() {
     19    assert.sameValue(counter++, 1, "The result of `counter++` is `1`");
     20    return 2;
     21  },
     22  toString: null
     23 };
     24 
     25 var object = {
     26  a: 'A',
     27  [key1]: 'B',
     28  c: 'C',
     29  [key2]: 'D',
     30 };
     31 assert.sameValue(counter, 2, "The value of `counter` is `2`");
     32 assert.sameValue(object.a, 'A', "The value of `object.a` is `'A'`. Defined as `a: 'A'`");
     33 assert.sameValue(object[1], 'B', "The value of `object[1]` is `'B'`. Defined as `[key1]: 'B'`");
     34 assert.sameValue(object.c, 'C', "The value of `object.c` is `'C'`. Defined as `c: 'C'`");
     35 assert.sameValue(object[2], 'D', "The value of `object[2]` is `'D'`. Defined as `[key2]: 'D'`");
     36 assert.compareArray(
     37  Object.getOwnPropertyNames(object),
     38  ['1', '2', 'a', 'c']
     39 );
     40 
     41 reportCompare(0, 0);