summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/es6/typedarray-map.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/mjsunit/es6/typedarray-map.js')
-rw-r--r--deps/v8/test/mjsunit/es6/typedarray-map.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/deps/v8/test/mjsunit/es6/typedarray-map.js b/deps/v8/test/mjsunit/es6/typedarray-map.js
new file mode 100644
index 0000000000..54b535fd30
--- /dev/null
+++ b/deps/v8/test/mjsunit/es6/typedarray-map.js
@@ -0,0 +1,49 @@
+// Copyright 2017 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.
+
+// Flags: --allow-natives-syntax
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array];
+
+function TestTypedArrayMap(constructor) {
+ assertEquals(1, constructor.prototype.map.length);
+
+ var target;
+
+ class EscapingArray extends constructor {
+ constructor(...args) {
+ super(...args);
+ target = this;
+ }
+ }
+
+ class DetachingArray extends constructor {
+ static get [Symbol.species]() {
+ return EscapingArray;
+ }
+ }
+
+ assertThrows(function(){
+ new DetachingArray(5).map(function(v,i,a){
+ print(i);
+ if (i == 1) {
+ %ArrayBufferNeuter(target.buffer);
+ }
+ })
+ }, TypeError);
+
+}
+
+for (i = 0; i < typedArrayConstructors.length; i++) {
+ TestTypedArrayMap(typedArrayConstructors[i]);
+}