| Index: test/mjsunit/es6/array-of-generic-1.js
|
| diff --git a/test/mjsunit/es6/array-of-generic-1.js b/test/mjsunit/es6/array-of-generic-1.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..33876907939b879e236fa0e759c002546741e1ae
|
| --- /dev/null
|
| +++ b/test/mjsunit/es6/array-of-generic-1.js
|
| @@ -0,0 +1,40 @@
|
| +// Copyright 2014 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.
|
| +
|
| +// Based on: https://hg.mozilla.org/mozilla-central/file/d0c3168c3c47/js/src/jit-test/tests/collections/Array-of-generic-1.js
|
| +
|
| +// Flags: --harmony-arrays
|
| +
|
| +
|
| +// Array.of can be transplanted to other classes.
|
| +
|
| +var hits = 0;
|
| +function Bag() {
|
| + hits++;
|
| +}
|
| +Bag.of = Array.of;
|
| +
|
| +hits = 0;
|
| +var actual = Bag.of("zero", "one");
|
| +assertEquals(hits, 1);
|
| +
|
| +hits = 0;
|
| +var expected = new Bag;
|
| +expected[0] = "zero";
|
| +expected[1] = "one";
|
| +expected.length = 2;
|
| +assertEquals(areSame(actual, expected), true);
|
| +
|
| +hits = 0;
|
| +actual = Array.of.call(Bag, "zero", "one");
|
| +assertEquals(hits, 1);
|
| +assertEquals(areSame(actual, expected), true);
|
| +
|
| +function areSame(object, array) {
|
| + var result = object.length == array.length;
|
| + for (var i = 0; i < object.length; i++) {
|
| + result = result && object[i] == array[i];
|
| + }
|
| + return result;
|
| +}
|
|
|