tor-browser

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

acquire-properties-from-object.js (1784B)


      1 // Copyright (C) 2011 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 es6id: 13.1
      5 description: >
      6    for-in to acquire properties from object
      7 ---*/
      8 function props(x) {
      9  var array = [];
     10  for (let p in x) array.push(p);
     11  return array;
     12 }
     13 var subject;
     14 
     15 subject = props({});
     16 assert.sameValue(subject.length, 0, "{}: length");
     17 assert.sameValue(subject[0], undefined, "{}: first property");
     18 assert.sameValue(subject[1], undefined, "{}: second property");
     19 assert.sameValue(subject[2], undefined, "{}: third property");
     20 assert.sameValue(subject[3], undefined, "{}: fourth property");
     21 
     22 subject = props({x:1});
     23 assert.sameValue(subject.length, 1, "{x:1}: length");
     24 assert.sameValue(subject[0], "x", "{x:1}: first property");
     25 assert.sameValue(subject[1], undefined, "{x:1}: second property");
     26 assert.sameValue(subject[2], undefined, "{x:1}: third property");
     27 assert.sameValue(subject[3], undefined, "{x:1}: fourth property");
     28 
     29 subject = props({x:1, y:2});
     30 assert.sameValue(subject.length, 2, "{x:1, y:2}: length");
     31 assert.sameValue(subject[0], "x", "{x:1, y:2}: first property");
     32 assert.sameValue(subject[1], "y", "{x:1, y:2}: second property");
     33 assert.sameValue(subject[2], undefined, "{x:1, y:2}: third property");
     34 assert.sameValue(subject[3], undefined, "{x:1, y:2}: fourth property");
     35 
     36 subject = props({x:1, y:2, zoom:3});
     37 assert.sameValue(subject.length, 3, "{x:1, y:2, zoom:3}: length");
     38 assert.sameValue(subject[0], "x", "{x:1, y:2, zoom:3}: first property");
     39 assert.sameValue(subject[1], "y", "{x:1, y:2, zoom:3}: second property");
     40 assert.sameValue(subject[2], "zoom", "{x:1, y:2, zoom:3}: third property");
     41 assert.sameValue(subject[3], undefined, "{x:1, y:2, zoom:3}: fourth property");
     42 
     43 reportCompare(0, 0);