tor-browser

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

construct-this-with-the-number-of-arguments.js (1136B)


      1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-array.of
      5 es6id: 22.1.2.3
      6 description: Passes the number of arguments to the constructor it calls.
      7 info: |
      8  Array.of ( ...items )
      9 
     10  1. Let len be the actual number of arguments passed to this function.
     11  2. Let items be the List of arguments passed to this function.
     12  3. Let C be the this value.
     13  4. If IsConstructor(C) is true, then
     14    a. Let A be Construct(C, «len»).
     15  ...
     16 ---*/
     17 
     18 var len;
     19 var hits = 0;
     20 
     21 function C(length) {
     22  len = length;
     23  hits++;
     24 }
     25 
     26 Array.of.call(C);
     27 assert.sameValue(len, 0, 'The value of len is expected to be 0');
     28 assert.sameValue(hits, 1, 'The value of hits is expected to be 1');
     29 
     30 Array.of.call(C, 'a', 'b')
     31 assert.sameValue(len, 2, 'The value of len is expected to be 2');
     32 assert.sameValue(hits, 2, 'The value of hits is expected to be 2');
     33 
     34 Array.of.call(C, false, null, undefined);
     35 assert.sameValue(
     36  len, 3,
     37  'The value of len is expected to be 3'
     38 );
     39 assert.sameValue(hits, 3, 'The value of hits is expected to be 3');
     40 
     41 reportCompare(0, 0);