TypedArray includes tests

This commit is contained in:
Natalie Silvanovich 2020-01-27 14:17:27 -08:00 committed by Rick Waldron
parent 2be0866895
commit 07e708d900
2 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,31 @@
// Copyright (C) 2020 Google. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.includes
description: Throws a TypeError if this has a detached buffer after index coercion
info: |
22.2.3.14 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
...
5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
...
includes: [testTypedArray.js, detachArrayBuffer.js]
features: [TypedArray]
---*/
testWithTypedArrayConstructors(function(TA) {
var sample = new TA(10);
function detachAndReturnIndex(){
$DETACHBUFFER(sample.buffer);
return 0;
}
assert.throws(TypeError, function() {
sample.includes(0, {valueOf :detachAndReturnIndex});
});
});

View File

@ -0,0 +1,31 @@
// Copyright (C) 2020 Google. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.includes
description: Throws a TypeError if this has an element that can detach the
buffer if coerced
info: |
22.2.3.14 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )
This function is not generic. ValidateTypedArray is applied to the this value
prior to evaluating the algorithm. If its result is an abrupt completion that
exception is thrown instead of evaluating the algorithm.
22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O )
...
5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
...
includes: [testTypedArray.js, detachArrayBuffer.js]
features: [TypedArray]
---*/
testWithTypedArrayConstructors(function(TA) {
var sample = new TA(10);
function throwFunc(){
throw Test262Error()
return 0;
}
assert.sameValue(sample.includes({valueOf : throwFunc}), false);
});