array-isarray.js 826 Bytes
Newer Older
1 2 3 4 5 6 7 8
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.


assertTrue(Array.isArray([]));
assertFalse(Array.isArray({}));
assertFalse(Array.isArray(null));
9 10 11 12
assertFalse(Array.isArray(0));
assertFalse(Array.isArray(0.1));
assertFalse(Array.isArray(""));
assertFalse(Array.isArray(undefined));
13 14 15 16 17 18

assertTrue(Array.isArray(new Proxy([], {})));
assertFalse(Array.isArray(new Proxy({}, {})));

assertTrue(Array.isArray(new Proxy(new Proxy([], {}), {})));
assertFalse(Array.isArray(new Proxy(new Proxy({}, {}), {})));
19 20 21 22 23 24 25 26

(function TestIsArrayStackOverflow() {
  var proxy = new Proxy([], {});
  for(var i=0; i<200*1024; i++) {
      proxy = new Proxy(proxy, {});
  }
  assertThrows(()=>Array.isArray(proxy), RangeError);
})();