mirror of https://github.com/tc39/test262.git
Add tests for TypedArray instance iterator methods
This commit is contained in:
parent
ba26b7f2dc
commit
b26190f1ce
|
@ -0,0 +1,36 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.2.3.6
|
||||
esid: sec-%typedarray%.prototype.entries
|
||||
description: Return an iterator for the entries.
|
||||
info: >
|
||||
22.2.3.6 %TypedArray%.prototype.entries ( )
|
||||
|
||||
...
|
||||
3. Return CreateArrayIterator(O, "key+value").
|
||||
includes: [testTypedArray.js, compareArray.js]
|
||||
---*/
|
||||
|
||||
var sample = new Int8Array([0, 42, 64]);
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var typedArray = new TA(sample);
|
||||
var itor = typedArray.entries();
|
||||
|
||||
var next = itor.next();
|
||||
assert(compareArray(next.value, [0, 0]));
|
||||
assert.sameValue(next.done, false);
|
||||
|
||||
next = itor.next();
|
||||
assert(compareArray(next.value, [1, 42]));
|
||||
assert.sameValue(next.done, false);
|
||||
|
||||
next = itor.next();
|
||||
assert(compareArray(next.value, [2, 64]));
|
||||
assert.sameValue(next.done, false);
|
||||
|
||||
next = itor.next();
|
||||
assert.sameValue(next.value, undefined);
|
||||
assert.sameValue(next.done, true);
|
||||
});
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.2.3.16
|
||||
esid: sec-%typedarray%.prototype.keys
|
||||
description: Return an iterator for the keys.
|
||||
info: >
|
||||
22.2.3.16 %TypedArray%.prototype.keys ( )
|
||||
|
||||
...
|
||||
3. Return CreateArrayIterator(O, "key").
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
var sample = new Int8Array([0, 42, 64]);
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var typedArray = new TA(sample);
|
||||
var itor = typedArray.keys();
|
||||
|
||||
var next = itor.next();
|
||||
assert.sameValue(next.value, 0);
|
||||
assert.sameValue(next.done, false);
|
||||
|
||||
next = itor.next();
|
||||
assert.sameValue(next.value, 1);
|
||||
assert.sameValue(next.done, false);
|
||||
|
||||
next = itor.next();
|
||||
assert.sameValue(next.value, 2);
|
||||
assert.sameValue(next.done, false);
|
||||
|
||||
next = itor.next();
|
||||
assert.sameValue(next.value, undefined);
|
||||
assert.sameValue(next.done, true);
|
||||
});
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 22.2.3.30
|
||||
esid: sec-%typedarray%.prototype.values
|
||||
description: Return an iterator for the values.
|
||||
info: >
|
||||
22.2.3.30 %TypedArray%.prototype.values ( )
|
||||
|
||||
...
|
||||
3. Return CreateArrayIterator(O, "value").
|
||||
includes: [testTypedArray.js]
|
||||
---*/
|
||||
|
||||
var sample = new Int8Array([0, 42, 64]);
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var typedArray = new TA(sample);
|
||||
var itor = typedArray.values();
|
||||
|
||||
var next = itor.next();
|
||||
assert.sameValue(next.value, 0);
|
||||
assert.sameValue(next.done, false);
|
||||
|
||||
next = itor.next();
|
||||
assert.sameValue(next.value, 42);
|
||||
assert.sameValue(next.done, false);
|
||||
|
||||
next = itor.next();
|
||||
assert.sameValue(next.value, 64);
|
||||
assert.sameValue(next.done, false);
|
||||
|
||||
next = itor.next();
|
||||
assert.sameValue(next.value, undefined);
|
||||
assert.sameValue(next.done, true);
|
||||
});
|
Loading…
Reference in New Issue