Skip to content

Commit

Permalink
Fix null-handling for equals in test and polyfill
Browse files Browse the repository at this point in the history
Equals specifically allows null inputs. Update the JS API tests
and the polyfill to match.
  • Loading branch information
ajklein authored and eqrion committed Sep 23, 2024
1 parent 7851a78 commit ab1be32
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/js-api/js-string/basic.tentative.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function assert_throws_if(func, shouldThrow, constructor) {
} catch (e) {
error = e;
}
assert_equals(error !== null, shouldThrow);
assert_equals(error !== null, shouldThrow, "shouldThrow mismatch");
if (shouldThrow && error !== null) {
assert_true(error instanceof constructor);
}
Expand Down Expand Up @@ -275,7 +275,7 @@ test(() => {
builtinExports['equals'],
polyfillExports['equals'],
a, a
), !isString, WebAssembly.RuntimeError);
), a !== null && !isString, WebAssembly.RuntimeError);

assert_throws_if(() => assert_same_behavior(
builtinExports['compare'],
Expand Down
4 changes: 2 additions & 2 deletions test/js-api/js-string/polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ this.polyfillImports = {
return string.substring(startIndex, endIndex);
},
equals: (stringA, stringB) => {
throwIfNotString(stringA);
throwIfNotString(stringB);
if (stringA !== null) throwIfNotString(stringA);
if (stringB !== null) throwIfNotString(stringB);
return stringA === stringB;
},
compare: (stringA, stringB) => {
Expand Down

0 comments on commit ab1be32

Please sign in to comment.