Skip to content
Snippets Groups Projects
Commit b26190f1 authored by Leonardo Balter's avatar Leonardo Balter Committed by Mike Pennisi
Browse files

Add tests for TypedArray instance iterator methods

parent ba26b7f2
No related branches found
No related tags found
No related merge requests found
// 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);
});
// 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);
});
// 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);
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment