Skip to content

Commit ab1be32

Browse files
ajkleineqrion
authored andcommitted
Fix null-handling for equals in test and polyfill
Equals specifically allows null inputs. Update the JS API tests and the polyfill to match.
1 parent 7851a78 commit ab1be32

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: test/js-api/js-string/basic.tentative.any.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ function assert_throws_if(func, shouldThrow, constructor) {
168168
} catch (e) {
169169
error = e;
170170
}
171-
assert_equals(error !== null, shouldThrow);
171+
assert_equals(error !== null, shouldThrow, "shouldThrow mismatch");
172172
if (shouldThrow && error !== null) {
173173
assert_true(error instanceof constructor);
174174
}
@@ -275,7 +275,7 @@ test(() => {
275275
builtinExports['equals'],
276276
polyfillExports['equals'],
277277
a, a
278-
), !isString, WebAssembly.RuntimeError);
278+
), a !== null && !isString, WebAssembly.RuntimeError);
279279

280280
assert_throws_if(() => assert_same_behavior(
281281
builtinExports['compare'],

Diff for: test/js-api/js-string/polyfill.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ this.polyfillImports = {
155155
return string.substring(startIndex, endIndex);
156156
},
157157
equals: (stringA, stringB) => {
158-
throwIfNotString(stringA);
159-
throwIfNotString(stringB);
158+
if (stringA !== null) throwIfNotString(stringA);
159+
if (stringB !== null) throwIfNotString(stringB);
160160
return stringA === stringB;
161161
},
162162
compare: (stringA, stringB) => {

0 commit comments

Comments
 (0)