Skip to content

Commit

Permalink
update detached buffer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Feb 8, 2024
1 parent 546543c commit 7f546b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-uint8array.prototype.setfrombase64
description: Uint8Array.prototype.setFromBase64 does not write to or error on detatched buffers
description: Uint8Array.prototype.setFromBase64 throws on detatched buffers
includes: [detachArrayBuffer.js]
features: [uint8array-base64]
---*/

var target = new Uint8Array([255, 255, 255]);
$DETACHBUFFER(target.buffer);
var result = target.setFromBase64('Zg==');
assert.sameValue(result.read, 0);
assert.sameValue(result.written, 0);
assert.throws(TypeError, function() {
target.setFromBase64('Zg==');
});

var getterCalls = 0;
var targetDetachingOptions = {};
Expand All @@ -23,7 +23,6 @@ Object.defineProperty(targetDetachingOptions, 'alphabet', {
}
});
var target = new Uint8Array([255, 255, 255]);
var result = target.setFromBase64('Zg==', targetDetachingOptions);
assert.sameValue(getterCalls, 1);
assert.sameValue(result.read, 0);
assert.sameValue(result.written, 0);
assert.throws(TypeError, function() {
target.setFromBase64('Zg==', targetDetachingOptions);
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-uint8array.prototype.setfromhex
description: Uint8Array.prototype.setFromHex does not write to or error on detatched buffers
description: Uint8Array.prototype.setFromHex throws on detatched buffers
includes: [detachArrayBuffer.js]
features: [uint8array-base64]
---*/

var target = new Uint8Array([255, 255, 255]);
$DETACHBUFFER(target.buffer);
var result = target.setFromHex('aa');
assert.sameValue(result.read, 0);
assert.sameValue(result.written, 0);
assert.throws(TypeError, function() {
target.setFromHex('aa');
});

0 comments on commit 7f546b3

Please sign in to comment.