| Index: test/mjsunit/es6/array-of-length-setter.js
|
| diff --git a/test/mjsunit/es6/array-of-length-setter.js b/test/mjsunit/es6/array-of-length-setter.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3b5b84eddde0ce605c078554266fdea84f4b0477
|
| --- /dev/null
|
| +++ b/test/mjsunit/es6/array-of-length-setter.js
|
| @@ -0,0 +1,35 @@
|
| +// 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-length-setter.js
|
| +
|
| +// Flags: --harmony-arrays
|
| +
|
| +
|
| +// Array.of calls a "length" setter if one is present.
|
| +
|
| +var hits = 0;
|
| +var lastObj = null, lastVal = undefined;
|
| +function setter(v) {
|
| + hits++;
|
| + lastObj = this;
|
| + lastVal = v;
|
| +}
|
| +
|
| +// when the setter is on the new object
|
| +function Pack() {
|
| + Object.defineProperty(this, "length", {set: setter});
|
| +}
|
| +Pack.of = Array.of;
|
| +var pack = Pack.of("wolves", "cards", "cigarettes", "lies");
|
| +assertEquals(lastObj, pack);
|
| +assertEquals(lastVal, 4);
|
| +
|
| +// when the setter is on the new object's prototype
|
| +function Bevy() {}
|
| +Object.defineProperty(Bevy.prototype, "length", {set: setter});
|
| +Bevy.of = Array.of;
|
| +var bevy = Bevy.of("quail");
|
| +assertEquals(lastObj, bevy);
|
| +assertEquals(lastVal, 1);
|
|
|