mirror of https://github.com/tc39/test262.git
fromBase64Into -> setFromBase64
This commit is contained in:
parent
bd05e23d40
commit
07807bd544
|
@ -1,16 +0,0 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.frombase64into
|
||||
description: Uint8Array.fromBase64Into ignores its receiver
|
||||
includes: [compareArray.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
var fromBase64Into = Uint8Array.fromBase64Into;
|
||||
var target = new Uint8Array([255, 255, 255]);
|
||||
|
||||
var result = fromBase64Into("Zg==", target);
|
||||
assert.sameValue(result.read, 4);
|
||||
assert.sameValue(result.written, 1);
|
||||
assert.compareArray(target, [102, 255, 255]);
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.fromhexinto
|
||||
description: Uint8Array.fromHexInto ignores its receiver
|
||||
includes: [compareArray.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
var fromHexInto = Uint8Array.fromHexInto;
|
||||
var target = new Uint8Array([255, 255, 255]);
|
||||
|
||||
var result = fromHexInto("aa", target);
|
||||
assert.sameValue(result.read, 2);
|
||||
assert.sameValue(result.written, 1);
|
||||
assert.compareArray(target, [170, 255, 255]);
|
|
@ -1,41 +1,41 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.frombase64into
|
||||
esid: sec-uint8array.prototype.setfrombase64
|
||||
description: Conversion of base64 strings to Uint8Arrays exercising the alphabet option
|
||||
includes: [compareArray.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
var target = new Uint8Array([255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('x+/y', target);
|
||||
var result = target.setFromBase64('x+/y');
|
||||
assert.sameValue(result.read, 4);
|
||||
assert.sameValue(result.written, 3);
|
||||
assert.compareArray(target, [199, 239, 242, 255]);
|
||||
|
||||
var target = new Uint8Array([255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('x+/y', target, { alphabet: 'base64' });
|
||||
var result = target.setFromBase64('x+/y', { alphabet: 'base64' });
|
||||
assert.sameValue(result.read, 4);
|
||||
assert.sameValue(result.written, 3);
|
||||
assert.compareArray(target, [199, 239, 242, 255]);
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
var target = new Uint8Array([255, 255, 255, 255]);
|
||||
Uint8Array.fromBase64('x+/y', { alphabet: 'base64url' });
|
||||
target.setFromBase64('x+/y', { alphabet: 'base64url' });
|
||||
});
|
||||
|
||||
|
||||
var target = new Uint8Array([255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('x-_y', target, { alphabet: 'base64url' });
|
||||
var result = target.setFromBase64('x-_y', { alphabet: 'base64url' });
|
||||
assert.sameValue(result.read, 4);
|
||||
assert.sameValue(result.written, 3);
|
||||
assert.compareArray(target, [199, 239, 242, 255]);
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
var target = new Uint8Array([255, 255, 255, 255]);
|
||||
Uint8Array.fromBase64('x-_y');
|
||||
target.setFromBase64('x-_y');
|
||||
});
|
||||
assert.throws(SyntaxError, function() {
|
||||
var target = new Uint8Array([255, 255, 255, 255]);
|
||||
Uint8Array.fromBase64('x-_y', { alphabet: 'base64' });
|
||||
target.setFromBase64('x-_y', { alphabet: 'base64' });
|
||||
});
|
|
@ -1,14 +1,14 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.fromhexinto
|
||||
esid: sec-uint8array.prototype.setfrombase64
|
||||
description: >
|
||||
Uint8Array.fromHexInto has default data property attributes.
|
||||
Uint8Array.prototype.setFromBase64 has default data property attributes.
|
||||
includes: [propertyHelper.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
verifyProperty(Uint8Array, 'fromHexInto', {
|
||||
verifyProperty(Uint8Array.prototype, 'setFromBase64', {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
|
@ -1,15 +1,15 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.frombase64into
|
||||
description: Uint8Array.fromBase64Into does not write to or error on detatched buffers
|
||||
esid: sec-uint8array.prototype.setfrombase64
|
||||
description: Uint8Array.prototype.setFromBase64 does not write to or error on detatched buffers
|
||||
includes: [detachArrayBuffer.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
var target = new Uint8Array([255, 255, 255]);
|
||||
$DETACHBUFFER(target.buffer);
|
||||
var result = Uint8Array.fromBase64Into('Zg==', target);
|
||||
var result = target.setFromBase64('Zg==');
|
||||
assert.sameValue(result.read, 0);
|
||||
assert.sameValue(result.written, 0);
|
||||
|
||||
|
@ -23,7 +23,7 @@ Object.defineProperty(targetDetachingOptions, 'alphabet', {
|
|||
}
|
||||
});
|
||||
var target = new Uint8Array([255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('Zg==', target, targetDetachingOptions);
|
||||
var result = target.setFromBase64('Zg==', targetDetachingOptions);
|
||||
assert.sameValue(getterCalls, 1);
|
||||
assert.sameValue(result.read, 0);
|
||||
assert.sameValue(result.written, 0);
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.frombase64into
|
||||
description: Uint8Array.fromBase64 throws a SyntaxError when input has non-base64, non-ascii-whitespace characters
|
||||
esid: sec-uint8array.prototype.setfrombase64
|
||||
description: Uint8Array.prototype.setFromBase64 throws a SyntaxError when input has non-base64, non-ascii-whitespace characters
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
|
@ -19,6 +19,6 @@ var illegal = [
|
|||
illegal.forEach(function(value) {
|
||||
assert.throws(SyntaxError, function() {
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255]);
|
||||
Uint8Array.fromBase64Into(value, target);
|
||||
target.setFromBase64(value);
|
||||
});
|
||||
});
|
|
@ -1,33 +1,33 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.frombase64into
|
||||
description: Handling of final chunks in Uint8Array.fromBase64Into
|
||||
esid: sec-uint8array.prototype.setfrombase64
|
||||
description: Handling of final chunks in target.setFromBase64
|
||||
includes: [compareArray.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
// padding
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('ZXhhZg==', target);
|
||||
var result = target.setFromBase64('ZXhhZg==');
|
||||
assert.sameValue(result.read, 8);
|
||||
assert.sameValue(result.written, 4);
|
||||
assert.compareArray(target, [101, 120, 97, 102, 255, 255]);
|
||||
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('ZXhhZg==', target, { lastChunkHandling: 'loose' });
|
||||
var result = target.setFromBase64('ZXhhZg==', { lastChunkHandling: 'loose' });
|
||||
assert.sameValue(result.read, 8);
|
||||
assert.sameValue(result.written, 4);
|
||||
assert.compareArray(target, [101, 120, 97, 102, 255, 255]);
|
||||
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('ZXhhZg==', target, { lastChunkHandling: 'stop-before-partial' });
|
||||
var result = target.setFromBase64('ZXhhZg==', { lastChunkHandling: 'stop-before-partial' });
|
||||
assert.sameValue(result.read, 8);
|
||||
assert.sameValue(result.written, 4);
|
||||
assert.compareArray(target, [101, 120, 97, 102, 255, 255]);
|
||||
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('ZXhhZg==', target, { lastChunkHandling: 'strict' });
|
||||
var result = target.setFromBase64('ZXhhZg==', { lastChunkHandling: 'strict' });
|
||||
assert.sameValue(result.read, 8);
|
||||
assert.sameValue(result.written, 4);
|
||||
assert.compareArray(target, [101, 120, 97, 102, 255, 255]);
|
||||
|
@ -35,97 +35,97 @@ assert.compareArray(target, [101, 120, 97, 102, 255, 255]);
|
|||
|
||||
// no padding
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('ZXhhZg', target);
|
||||
var result = target.setFromBase64('ZXhhZg');
|
||||
assert.sameValue(result.read, 6);
|
||||
assert.sameValue(result.written, 4);
|
||||
assert.compareArray(target, [101, 120, 97, 102, 255, 255]);
|
||||
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('ZXhhZg', target, { lastChunkHandling: 'loose' });
|
||||
var result = target.setFromBase64('ZXhhZg', { lastChunkHandling: 'loose' });
|
||||
assert.sameValue(result.read, 6);
|
||||
assert.sameValue(result.written, 4);
|
||||
assert.compareArray(target, [101, 120, 97, 102, 255, 255]);
|
||||
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('ZXhhZg', target, { lastChunkHandling: 'stop-before-partial' });
|
||||
var result = target.setFromBase64('ZXhhZg', { lastChunkHandling: 'stop-before-partial' });
|
||||
assert.sameValue(result.read, 4);
|
||||
assert.sameValue(result.written, 3);
|
||||
assert.compareArray(target, [101, 120, 97, 255, 255, 255]);
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
Uint8Array.fromBase64Into('ZXhhZg', target, { lastChunkHandling: 'strict' });
|
||||
target.setFromBase64('ZXhhZg', { lastChunkHandling: 'strict' });
|
||||
});
|
||||
|
||||
|
||||
// non-zero padding bits
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('ZXhhZh==', target);
|
||||
var result = target.setFromBase64('ZXhhZh==');
|
||||
assert.sameValue(result.read, 8);
|
||||
assert.sameValue(result.written, 4);
|
||||
assert.compareArray(target, [101, 120, 97, 102, 255, 255]);
|
||||
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('ZXhhZh==', target, { lastChunkHandling: 'loose' });
|
||||
var result = target.setFromBase64('ZXhhZh==', { lastChunkHandling: 'loose' });
|
||||
assert.sameValue(result.read, 8);
|
||||
assert.sameValue(result.written, 4);
|
||||
assert.compareArray(target, [101, 120, 97, 102, 255, 255]);
|
||||
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('ZXhhZh==', target, { lastChunkHandling: 'stop-before-partial' });
|
||||
var result = target.setFromBase64('ZXhhZh==', { lastChunkHandling: 'stop-before-partial' });
|
||||
assert.sameValue(result.read, 8);
|
||||
assert.sameValue(result.written, 4);
|
||||
assert.compareArray(target, [101, 120, 97, 102, 255, 255]);
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
Uint8Array.fromBase64Into('ZXhhZh==', target, { lastChunkHandling: 'strict' });
|
||||
target.setFromBase64('ZXhhZh==', { lastChunkHandling: 'strict' });
|
||||
});
|
||||
|
||||
|
||||
// non-zero padding bits, no padding
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('ZXhhZh', target);
|
||||
var result = target.setFromBase64('ZXhhZh');
|
||||
assert.sameValue(result.read, 6);
|
||||
assert.sameValue(result.written, 4);
|
||||
assert.compareArray(target, [101, 120, 97, 102, 255, 255]);
|
||||
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('ZXhhZh', target, { lastChunkHandling: 'loose' });
|
||||
var result = target.setFromBase64('ZXhhZh', { lastChunkHandling: 'loose' });
|
||||
assert.sameValue(result.read, 6);
|
||||
assert.sameValue(result.written, 4);
|
||||
assert.compareArray(target, [101, 120, 97, 102, 255, 255]);
|
||||
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('ZXhhZh', target, { lastChunkHandling: 'stop-before-partial' });
|
||||
var result = target.setFromBase64('ZXhhZh', { lastChunkHandling: 'stop-before-partial' });
|
||||
assert.sameValue(result.read, 4);
|
||||
assert.sameValue(result.written, 3);
|
||||
assert.compareArray(target, [101, 120, 97, 255, 255, 255]);
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
Uint8Array.fromBase64Into('ZXhhZh', target, { lastChunkHandling: 'strict' });
|
||||
target.setFromBase64('ZXhhZh', { lastChunkHandling: 'strict' });
|
||||
});
|
||||
|
||||
|
||||
// malformed padding
|
||||
assert.throws(SyntaxError, function() {
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
Uint8Array.fromBase64Into('ZXhhZg=', target);
|
||||
target.setFromBase64('ZXhhZg=');
|
||||
});
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
Uint8Array.fromBase64Into('ZXhhZg=', target, { lastChunkHandling: 'loose' });
|
||||
target.setFromBase64('ZXhhZg=', { lastChunkHandling: 'loose' });
|
||||
});
|
||||
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('ZXhhZg=', target, { lastChunkHandling: 'stop-before-partial' });
|
||||
var result = target.setFromBase64('ZXhhZg=', { lastChunkHandling: 'stop-before-partial' });
|
||||
assert.sameValue(result.read, 4);
|
||||
assert.sameValue(result.written, 3);
|
||||
assert.compareArray(target, [101, 120, 97, 255, 255, 255]);
|
||||
|
||||
assert.throws(SyntaxError, function() {
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
Uint8Array.fromBase64Into('ZXhhZg=', target, { lastChunkHandling: 'strict' });
|
||||
target.setFromBase64('ZXhhZg=', { lastChunkHandling: 'strict' });
|
||||
});
|
|
@ -1,15 +1,15 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.frombase64into
|
||||
esid: sec-uint8array.prototype.setfrombase64
|
||||
description: >
|
||||
Uint8Array.fromBase64Into.length is 2.
|
||||
Uint8Array.prototype.setFromBase64.length is 1.
|
||||
includes: [propertyHelper.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
verifyProperty(Uint8Array.fromBase64Into, 'length', {
|
||||
value: 2,
|
||||
verifyProperty(Uint8Array.prototype.setFromBase64, 'length', {
|
||||
value: 1,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: true
|
|
@ -1,15 +1,15 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.fromhexinto
|
||||
esid: sec-uint8array.prototype.setfrombase64
|
||||
description: >
|
||||
Uint8Array.fromHexInto.name is "fromHexInto".
|
||||
Uint8Array.prototype.setFromBase64.name is "setFromBase64".
|
||||
includes: [propertyHelper.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
verifyProperty(Uint8Array.fromHexInto, 'name', {
|
||||
value: 'fromHexInto',
|
||||
verifyProperty(Uint8Array.prototype.setFromBase64, 'name', {
|
||||
value: 'setFromBase64',
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: true
|
|
@ -1,16 +1,16 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.frombase64into
|
||||
esid: sec-uint8array.prototype.setfrombase64
|
||||
description: >
|
||||
Uint8Array.fromBase64Into is not a constructor function.
|
||||
Uint8Array.prototype.setFromBase64 is not a constructor function.
|
||||
includes: [isConstructor.js]
|
||||
features: [uint8array-base64, Reflect.construct]
|
||||
---*/
|
||||
|
||||
assert(!isConstructor(Uint8Array.fromBase64Into), "Uint8Array.fromBase64Into is not a constructor");
|
||||
assert(!isConstructor(Uint8Array.prototype.setFromBase64), "Uint8Array.prototype.setFromBase64 is not a constructor");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var target = new Uint8Array(10);
|
||||
new Uint8Array.fromBase64Into('', target);
|
||||
new target.setFromBase64('');
|
||||
});
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.frombase64into
|
||||
description: Uint8Array.fromBase64Into triggers effects of the "alphabet" and "lastChunkHandling" getters, but does not perform toString on the results
|
||||
esid: sec-uint8array.prototype.setfrombase64
|
||||
description: Uint8Array.prototype.setFromBase64 triggers effects of the "alphabet" and "lastChunkHandling" getters, but does not perform toString on the results
|
||||
includes: [compareArray.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
@ -16,13 +16,13 @@ var throwyToString = {
|
|||
};
|
||||
assert.throws(TypeError, function() {
|
||||
var target = new Uint8Array([255, 255, 255]);
|
||||
Uint8Array.fromBase64Into("Zg==", target, { alphabet: throwyToString });
|
||||
target.setFromBase64("Zg==", { alphabet: throwyToString });
|
||||
});
|
||||
assert.sameValue(toStringCalls, 0);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var target = new Uint8Array([255, 255, 255]);
|
||||
Uint8Array.fromBase64Into("Zg==", target, { lastChunkHandling: throwyToString });
|
||||
target.setFromBase64("Zg==", { lastChunkHandling: throwyToString });
|
||||
});
|
||||
assert.sameValue(toStringCalls, 0);
|
||||
|
||||
|
@ -36,7 +36,7 @@ Object.defineProperty(base64UrlOptions, "alphabet", {
|
|||
}
|
||||
});
|
||||
var target = new Uint8Array([255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into("x-_y", target, base64UrlOptions);
|
||||
var result = target.setFromBase64("x-_y", base64UrlOptions);
|
||||
assert.sameValue(result.read, 4);
|
||||
assert.sameValue(result.written, 3);
|
||||
assert.compareArray(target, [199, 239, 242, 255]);
|
||||
|
@ -51,7 +51,7 @@ Object.defineProperty(strictOptions, "lastChunkHandling", {
|
|||
}
|
||||
});
|
||||
var target = new Uint8Array([255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into("Zg==", target, strictOptions);
|
||||
var result = target.setFromBase64("Zg==", strictOptions);
|
||||
assert.sameValue(result.read, 4);
|
||||
assert.sameValue(result.written, 1);
|
||||
assert.compareArray(target, [102, 255, 255, 255]);
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.frombase64into
|
||||
esid: sec-uint8array.prototype.setfrombase64
|
||||
description: Conversion of base64 strings to Uint8Arrays
|
||||
includes: [compareArray.js]
|
||||
features: [uint8array-base64]
|
||||
|
@ -21,7 +21,7 @@ var standardBase64Vectors = [
|
|||
standardBase64Vectors.forEach(function (pair) {
|
||||
var allFF = [255, 255, 255, 255, 255, 255, 255, 255];
|
||||
var target = new Uint8Array(allFF);
|
||||
var result = Uint8Array.fromBase64Into(pair[0], target);
|
||||
var result = target.setFromBase64(pair[0]);
|
||||
assert.sameValue(result.read, pair[0].length);
|
||||
assert.sameValue(result.written, pair[1].length);
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.frombase64into
|
||||
description: Uint8Array.fromBase64Into throws if its first argument is not a string
|
||||
esid: sec-uint8array.prototype.setfrombase64
|
||||
description: Uint8Array.prototype.setFromBase64 throws if its first argument is not a string
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
|
@ -16,7 +16,7 @@ var throwyToString = {
|
|||
|
||||
assert.throws(TypeError, function() {
|
||||
var target = new Uint8Array(10);
|
||||
Uint8Array.fromBase64Into(throwyToString, target);
|
||||
target.setFromBase64(throwyToString);
|
||||
});
|
||||
assert.sameValue(toStringCalls, 0);
|
||||
|
||||
|
@ -37,7 +37,7 @@ Object.defineProperty(touchyOptions, "lastChunkHandling", {
|
|||
});
|
||||
assert.throws(TypeError, function() {
|
||||
var target = new Uint8Array(10);
|
||||
Uint8Array.fromBase64Into(throwyToString, target, touchyOptions);
|
||||
target.setFromBase64(throwyToString, touchyOptions);
|
||||
});
|
||||
assert.sameValue(toStringCalls, 0);
|
||||
assert.sameValue(optionAccesses, 0);
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.frombase64into
|
||||
description: Uint8Array.fromBase64Into takes into account the offset of the target Uint8Array
|
||||
esid: sec-uint8array.prototype.setfrombase64
|
||||
description: Uint8Array.prototype.setFromBase64 takes into account the offset of the target Uint8Array
|
||||
includes: [compareArray.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
@ -10,7 +10,7 @@ features: [uint8array-base64]
|
|||
var base = new Uint8Array([255, 255, 255, 255, 255, 255, 255]);
|
||||
var subarray = base.subarray(2, 5);
|
||||
|
||||
var result = Uint8Array.fromBase64Into('Zm9vYmFy', subarray);
|
||||
var result = subarray.setFromBase64('Zm9vYmFy');
|
||||
assert.sameValue(result.read, 4);
|
||||
assert.sameValue(result.written, 3);
|
||||
assert.compareArray(subarray, [102, 111, 111]);
|
|
@ -1,64 +1,64 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.frombase64
|
||||
description: Uint8Array.fromBase64Into behavior when target buffer is small
|
||||
esid: sec-uint8array.prototype.setfrombase64
|
||||
description: Uint8Array.prototype.setFromBase64 behavior when target buffer is small
|
||||
includes: [compareArray.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
// buffer too small
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('Zm9vYmFy', target);
|
||||
var result = target.setFromBase64('Zm9vYmFy');
|
||||
assert.sameValue(result.read, 4);
|
||||
assert.sameValue(result.written, 3);
|
||||
assert.compareArray(target, [102, 111, 111, 255, 255]);
|
||||
|
||||
// buffer too small, padded
|
||||
var target = new Uint8Array([255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('Zm9vYmE=', target);
|
||||
var result = target.setFromBase64('Zm9vYmE=');
|
||||
assert.sameValue(result.read, 4);
|
||||
assert.sameValue(result.written, 3);
|
||||
assert.compareArray(target, [102, 111, 111, 255]);
|
||||
|
||||
// buffer exact
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('Zm9vYmFy', target);
|
||||
var result = target.setFromBase64('Zm9vYmFy');
|
||||
assert.sameValue(result.read, 8);
|
||||
assert.sameValue(result.written, 6);
|
||||
assert.compareArray(target, [102, 111, 111, 98, 97, 114]);
|
||||
|
||||
// buffer exact, padded
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('Zm9vYmE=', target);
|
||||
var result = target.setFromBase64('Zm9vYmE=');
|
||||
assert.sameValue(result.read, 8);
|
||||
assert.sameValue(result.written, 5);
|
||||
assert.compareArray(target, [102, 111, 111, 98, 97]);
|
||||
|
||||
// buffer exact, not padded
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('Zm9vYmE', target);
|
||||
var result = target.setFromBase64('Zm9vYmE');
|
||||
assert.sameValue(result.read, 7);
|
||||
assert.sameValue(result.written, 5);
|
||||
assert.compareArray(target, [102, 111, 111, 98, 97]);
|
||||
|
||||
// buffer exact, padded, stop-before-partial
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('Zm9vYmE=', target, { lastChunkHandling: 'stop-before-partial' });
|
||||
var result = target.setFromBase64('Zm9vYmE=', { lastChunkHandling: 'stop-before-partial' });
|
||||
assert.sameValue(result.read, 8);
|
||||
assert.sameValue(result.written, 5);
|
||||
assert.compareArray(target, [102, 111, 111, 98, 97]);
|
||||
|
||||
// buffer exact, not padded, stop-before-partial
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('Zm9vYmE', target, { lastChunkHandling: 'stop-before-partial' });
|
||||
var result = target.setFromBase64('Zm9vYmE', { lastChunkHandling: 'stop-before-partial' });
|
||||
assert.sameValue(result.read, 4);
|
||||
assert.sameValue(result.written, 3);
|
||||
assert.compareArray(target, [102, 111, 111, 255, 255]);
|
||||
|
||||
// buffer too large
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into('Zm9vYmFy', target);
|
||||
var result = target.setFromBase64('Zm9vYmFy');
|
||||
assert.sameValue(result.read, 8);
|
||||
assert.sameValue(result.written, 6);
|
||||
assert.compareArray(target, [102, 111, 111, 98, 97, 114, 255]);
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.frombase64into
|
||||
description: Uint8Array.fromBase64Into ignores ASCII whitespace in the input
|
||||
esid: sec-uint8array.prototype.setfrombase64
|
||||
description: Uint8Array.prototype.setFromBase64 ignores ASCII whitespace in the input
|
||||
includes: [compareArray.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
@ -16,7 +16,7 @@ var whitespaceKinds = [
|
|||
];
|
||||
whitespaceKinds.forEach(function(pair) {
|
||||
var target = new Uint8Array([255, 255, 255]);
|
||||
var result = Uint8Array.fromBase64Into(pair[0], target);
|
||||
var result = target.setFromBase64(pair[0]);
|
||||
assert.sameValue(result.read, 5);
|
||||
assert.sameValue(result.written, 1);
|
||||
assert.compareArray(target, [102, 255, 255], "ascii whitespace: " + pair[1]);
|
|
@ -1,14 +1,14 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.frombase64into
|
||||
esid: sec-uint8array.prototype.setfromhex
|
||||
description: >
|
||||
Uint8Array.fromBase64Into has default data property attributes.
|
||||
Uint8Array.prototype.setFromHex has default data property attributes.
|
||||
includes: [propertyHelper.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
verifyProperty(Uint8Array, 'fromBase64Into', {
|
||||
verifyProperty(Uint8Array.prototype, 'setFromHex', {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
|
@ -1,14 +1,14 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.fromhexinto
|
||||
description: Uint8Array.fromHexInto does not write to or error on detatched buffers
|
||||
esid: sec-uint8array.prototype.setfromhex
|
||||
description: Uint8Array.prototype.setFromHex does not write to or error on detatched buffers
|
||||
includes: [detachArrayBuffer.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
var target = new Uint8Array([255, 255, 255]);
|
||||
$DETACHBUFFER(target.buffer);
|
||||
var result = Uint8Array.fromHexInto('aa', target);
|
||||
var result = target.setFromHex('aa');
|
||||
assert.sameValue(result.read, 0);
|
||||
assert.sameValue(result.written, 0);
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.fromhexinto
|
||||
description: Uint8Array.fromHexInto throws a SyntaxError when input has non-hex characters
|
||||
esid: sec-uint8array.prototype.setfromhex
|
||||
description: Uint8Array.prototype.setFromHex throws a SyntaxError when input has non-hex characters
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
|
@ -21,6 +21,6 @@ var illegal = [
|
|||
illegal.forEach(function(value) {
|
||||
assert.throws(SyntaxError, function() {
|
||||
var target = new Uint8Array([255, 255, 255, 255, 255]);
|
||||
Uint8Array.fromHexInto(value, target);
|
||||
target.setFromHex(value);
|
||||
});
|
||||
});
|
|
@ -1,15 +1,15 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.fromhexinto
|
||||
esid: sec-uint8array.prototype.setfromhex
|
||||
description: >
|
||||
Uint8Array.fromHexInto.length is 2.
|
||||
Uint8Array.prototype.setFromHex.length is 1.
|
||||
includes: [propertyHelper.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
verifyProperty(Uint8Array.fromHexInto, 'length', {
|
||||
value: 2,
|
||||
verifyProperty(Uint8Array.prototype.setFromHex, 'length', {
|
||||
value: 1,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: true
|
|
@ -1,15 +1,15 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.frombase64into
|
||||
esid: sec-uint8array.prototype.setfromhex
|
||||
description: >
|
||||
Uint8Array.fromBase64Into.name is "fromBase64Into".
|
||||
Uint8Array.prototype.setFromHex.name is "setFromHex".
|
||||
includes: [propertyHelper.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
verifyProperty(Uint8Array.fromBase64Into, 'name', {
|
||||
value: 'fromBase64Into',
|
||||
verifyProperty(Uint8Array.prototype.setFromHex, 'name', {
|
||||
value: 'setFromHex',
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: true
|
|
@ -1,16 +1,16 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.fromhexinto
|
||||
esid: sec-uint8array.prototype.setfromhex
|
||||
description: >
|
||||
Uint8Array.fromHexInto is not a constructor function.
|
||||
Uint8Array.prototype.setFromHex is not a constructor function.
|
||||
includes: [isConstructor.js]
|
||||
features: [uint8array-base64, Reflect.construct]
|
||||
---*/
|
||||
|
||||
assert(!isConstructor(Uint8Array.fromHexInto), "Uint8Array.fromHexInto is not a constructor");
|
||||
assert(!isConstructor(Uint8Array.prototype.setFromHex), "target.setFromHex is not a constructor");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
var target = new Uint8Array(10);
|
||||
new Uint8Array.fromHexInto('', target);
|
||||
new target.setFromHex('');
|
||||
});
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.fromhexinto
|
||||
esid: sec-uint8array.prototype.setfromhex
|
||||
description: Conversion of hex strings to Uint8Arrays
|
||||
includes: [compareArray.js]
|
||||
features: [uint8array-base64]
|
||||
|
@ -22,7 +22,7 @@ var cases = [
|
|||
cases.forEach(function (pair) {
|
||||
var allFF = [255, 255, 255, 255, 255, 255, 255, 255];
|
||||
var target = new Uint8Array(allFF);
|
||||
var result = Uint8Array.fromHexInto(pair[0], target);
|
||||
var result = target.setFromHex(pair[0]);
|
||||
assert.sameValue(result.read, pair[0].length);
|
||||
assert.sameValue(result.written, pair[1].length);
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.fromhexinto
|
||||
description: Uint8Array.fromHexInto throws if its first argument is not a string
|
||||
esid: sec-uint8array.prototype.setfromhex
|
||||
description: Uint8Array.prototype.setFromHex throws if its first argument is not a string
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
|
@ -16,6 +16,6 @@ var throwyToString = {
|
|||
|
||||
assert.throws(TypeError, function() {
|
||||
var target = new Uint8Array(10);
|
||||
Uint8Array.fromHexInto(throwyToString, target);
|
||||
target.setFromHex(throwyToString);
|
||||
});
|
||||
assert.sameValue(toStringCalls, 0);
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.fromhexinto
|
||||
description: Uint8Array.fromHexInto takes into account the offset of the target Uint8Array
|
||||
esid: sec-uint8array.prototype.setfromhex
|
||||
description: Uint8Array.prototype.setFromHex takes into account the offset of the target Uint8Array
|
||||
includes: [compareArray.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
@ -10,7 +10,7 @@ features: [uint8array-base64]
|
|||
var base = new Uint8Array([255, 255, 255, 255, 255, 255, 255]);
|
||||
var subarray = base.subarray(2, 5);
|
||||
|
||||
var result = Uint8Array.fromHexInto('aabbcc', subarray);
|
||||
var result = subarray.setFromHex('aabbcc');
|
||||
assert.sameValue(result.read, 6);
|
||||
assert.sameValue(result.written, 3);
|
||||
assert.compareArray(subarray, [170, 187, 204]);
|
|
@ -1,29 +1,29 @@
|
|||
// Copyright (C) 2024 Kevin Gibbons. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-uint8array.fromhexinto
|
||||
description: Uint8Array.fromHexInto behavior when target buffer is small
|
||||
esid: sec-uint8array.prototype.setfromhex
|
||||
description: Uint8Array.prototype.setFromHex behavior when target buffer is small
|
||||
includes: [compareArray.js]
|
||||
features: [uint8array-base64]
|
||||
---*/
|
||||
|
||||
// buffer too small
|
||||
var target = new Uint8Array([255, 255]);
|
||||
var result = Uint8Array.fromHexInto('aabbcc', target);
|
||||
var result = target.setFromHex('aabbcc');
|
||||
assert.sameValue(result.read, 4);
|
||||
assert.sameValue(result.written, 2);
|
||||
assert.compareArray(target, [170, 187]);
|
||||
|
||||
// buffer exact
|
||||
var target = new Uint8Array([255, 255, 255]);
|
||||
var result = Uint8Array.fromHexInto('aabbcc', target);
|
||||
var result = target.setFromHex('aabbcc');
|
||||
assert.sameValue(result.read, 6);
|
||||
assert.sameValue(result.written, 3);
|
||||
assert.compareArray(target, [170, 187, 204]);
|
||||
|
||||
// buffer too large
|
||||
var target = new Uint8Array([255, 255, 255, 255]);
|
||||
var result = Uint8Array.fromHexInto('aabbcc', target);
|
||||
var result = target.setFromHex('aabbcc');
|
||||
assert.sameValue(result.read, 6);
|
||||
assert.sameValue(result.written, 3);
|
||||
assert.compareArray(target, [170, 187, 204, 255]);
|
Loading…
Reference in New Issue