Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support normative change to Resizable ArrayBuffer #3163

Merged
merged 1 commit into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,12 @@ testWithTypedArrayConstructors(function(TA) {
expected = 0;
} catch (_) {}

assert.sameValue(array.byteLength, expected, "following shrink (on boundary)");

try {
ab.resize(0);
expected = 0;
} catch (_) {}

assert.sameValue(array.byteLength, expected, "following shrink (out of bounds)");
});
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@ testWithTypedArrayConstructors(function(TA) {

assert.sameValue(array.byteOffset, BPE, "following shrink (within bounds)");

var expected;
var expected = BPE;
try {
ab.resize(BPE);
expected = 0;
} catch (_) {
expected = BPE;
}
} catch (_) {}

assert.sameValue(array.byteOffset, expected, "following shrink (on boundary)");

try {
ab.resize(0);
expected = 0;
} catch (_) {}

assert.sameValue(array.byteOffset, expected, "following shrink (out of bounds)");
});
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,12 @@ testWithTypedArrayConstructors(function(TA) {
expected = 0;
} catch (_) {}

assert.sameValue(array.length, expected, "following shrink (on boundary)");

try {
ab.resize(0);
expected = 0;
} catch (_) {}

assert.sameValue(array.length, expected, "following shrink (out of bounds)");
});
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,22 @@ testWithTypedArrayConstructors(function(TA) {

assert(compareArray(new TargetCtor(source), expected), 'following shrink (within bounds)');

onGetSpecies = function() {
try {
ab.resize(BPE);
expected = [];
} catch (_) {}
};

assert(compareArray(new TargetCtor(source), expected), 'following shrink (on boundary)');

// `assert.throws` cannot be used in this case because the expected error
// is derived only after the constructor is invoked.
var expectedError;
var actualError;
onGetSpecies = function() {
try {
ab.resize(BPE);
ab.resize(0);
expectedError = TypeError;
} catch (_) {
expectedError = Test262Error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,22 @@ testWithTypedArrayConstructors(function(TA) {

assert(compareArray(new TA(source), expected), 'following shrink (within bounds)');

onGetSpecies = function() {
try {
ab.resize(BPE);
expected = [];
} catch (_) {}
};

assert(compareArray(new TA(source), expected), 'following shrink (on boundary)');

// `assert.throws` cannot be used in this case because the expected error
// is derived only after the constructor is invoked.
var expectedError;
var actualError;
onGetSpecies = function() {
try {
ab.resize(BPE);
ab.resize(0);
expectedError = TypeError;
} catch (_) {
expectedError = Test262Error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,12 @@ testWithTypedArrayConstructors(function(TA) {
expected = "false,false,false,false,false";
} catch (_) {}

assert.sameValue(inspect(array), expected, "following shrink (on boundary)");

try {
ab.resize(0);
expected = "false,false,false,false,false";
} catch (_) {}

assert.sameValue(inspect(array), expected, "following shrink (out of bounds)");
});
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ testWithTypedArrayConstructors(function(TA) {
expected = "";
} catch (_) {}

assert.sameValue(
Reflect.ownKeys(array).join(","), expected, "following shrink (on boundary)"
);

try {
ab.resize(0);
expected = "";
} catch (_) {}

assert.sameValue(
Reflect.ownKeys(array).join(","), expected, "following shrink (out of bounds)"
);
Expand Down