Commit 86a27207 authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[test] Make assertThrowsEquals use assertSame

The typical use of assertThrowsEquals is to check that a specific
object is thrown. However, assertEquals only does a proper equality
check for primitive types, not for complex types. Using assertSame
does a reference equality check on objects, which is more what you
would expect from assertThrowsEquals. For exception kind testing,
assertThrowsEquals actually did not work correctly, assertThrows is
better for that case.

R=clemensh@chromium.org, mythria@chromium.org

Change-Id: I24fb22e75fa33ebe90eb4bae40825119a054bba5
Reviewed-on: https://chromium-review.googlesource.com/1087952Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53556}
parent 3252af39
...@@ -16,5 +16,5 @@ f(0); ...@@ -16,5 +16,5 @@ f(0);
f(0); f(0);
assertOptimized(f); assertOptimized(f);
// Check that hole checks are handled correctly in optimized code. // Check that hole checks are handled correctly in optimized code.
assertThrowsEquals(() => {f(1)}, ReferenceError()); assertThrows(() => {f(1)}, ReferenceError);
assertOptimized(f); assertOptimized(f);
...@@ -18,11 +18,11 @@ class B extends A { ...@@ -18,11 +18,11 @@ class B extends A {
test = new B(0); test = new B(0);
test = new B(0); test = new B(0);
assertThrowsEquals(() => {new B(1)}, ReferenceError()); assertThrows(() => {new B(1)}, ReferenceError);
assertThrowsEquals(() => {new B(1)}, ReferenceError()); assertThrows(() => {new B(1)}, ReferenceError);
%OptimizeFunctionOnNextCall(B); %OptimizeFunctionOnNextCall(B);
test = new B(0); test = new B(0);
assertOptimized(B); assertOptimized(B);
// Check that hole checks are handled correctly in optimized code. // Check that hole checks are handled correctly in optimized code.
assertThrowsEquals(() => {new B(1)}, ReferenceError()); assertThrows(() => {new B(1)}, ReferenceError);
assertOptimized(B); assertOptimized(B);
...@@ -21,5 +21,5 @@ test = new B(1); ...@@ -21,5 +21,5 @@ test = new B(1);
test = new B(1); test = new B(1);
assertOptimized(B); assertOptimized(B);
// Check that hole checks are handled correctly in optimized code. // Check that hole checks are handled correctly in optimized code.
assertThrowsEquals(() => {new B(0)}, ReferenceError()); assertThrows(() => {new B(0)}, ReferenceError);
assertOptimized(B); assertOptimized(B);
...@@ -506,7 +506,7 @@ var prettyPrinted; ...@@ -506,7 +506,7 @@ var prettyPrinted;
try { try {
fun(); fun();
} catch(e) { } catch(e) {
assertEquals(val, e); assertSame(val, e);
return; return;
} }
failWithMessage("Did not throw exception"); failWithMessage("Did not throw exception");
......
...@@ -126,11 +126,15 @@ assertThrows(() => {instantiate(kSig_i_v, [kExprI32Const, 0]);}); ...@@ -126,11 +126,15 @@ assertThrows(() => {instantiate(kSig_i_v, [kExprI32Const, 0]);});
(function testStartFunctionThrowsExplicitly() { (function testStartFunctionThrowsExplicitly() {
print('testStartFunctionThrowsExplicitly'); print('testStartFunctionThrowsExplicitly');
let error = new Error('my explicit error'); let error = new Error('my explicit error');
function throw_fn() { var ffi = {
foo: {
throw_fn: function() {
throw error; throw error;
} }
}
};
let builder = new WasmModuleBuilder(); let builder = new WasmModuleBuilder();
builder.addImport('foo', 'bar', kSig_v_v); builder.addImport('foo', 'throw_fn', kSig_v_v);
let func = builder.addFunction('', kSig_v_v).addBody([kExprCallFunction, 0]); let func = builder.addFunction('', kSig_v_v).addBody([kExprCallFunction, 0]);
builder.addStart(func.index); builder.addStart(func.index);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment