Commit 6ff2dbc1 authored by rtoy's avatar rtoy Committed by Commit bot

Treat should().throw(undefined) like should().throw()

Interpret throw(undefined) to mean that an error of any type is
expected.  This is the same as throw().

BUG=706558
TEST=audit.html

Review-Url: https://codereview.chromium.org/2783033002
Cr-Commit-Position: refs/heads/master@{#460584}
parent 7b657dbe
...@@ -287,7 +287,7 @@ window.Audit = (function () { ...@@ -287,7 +287,7 @@ window.Audit = (function () {
// Catch did not happen, so the test is failed. // Catch did not happen, so the test is failed.
failDetail = '${actual} did not throw an exception.'; failDetail = '${actual} did not throw an exception.';
} catch (error) { } catch (error) {
if (this._expected === null) { if (this._expected === null || this._expected === undefined) {
// The expected error type was not given. // The expected error type was not given.
didThrowCorrectly = true; didThrowCorrectly = true;
passDetail = '${actual} threw ' + error.name + ': "' passDetail = '${actual} threw ' + error.name + ': "'
......
...@@ -21,6 +21,8 @@ PASS OfflineAudioContext does exist. ...@@ -21,6 +21,8 @@ PASS OfflineAudioContext does exist.
PASS Setting foo1 to 0 did not throw an exception. PASS Setting foo1 to 0 did not throw an exception.
PASS function () { var foo2 = bar; } threw ReferenceError: "bar is not defined". PASS function () { var foo2 = bar; } threw ReferenceError: "bar is not defined".
PASS function () { var foo3 = bar; } threw ReferenceError: "bar is not defined". PASS function () { var foo3 = bar; } threw ReferenceError: "bar is not defined".
PASS function () { var foo4 = bar; } threw ReferenceError: "bar is not defined".
PASS function () { var foo5 = bar; } threw ReferenceError: "bar is not defined".
PASS Calling should() with no argument threw Error: "Task.should:: requires at least 1 argument.". PASS Calling should() with no argument threw Error: "Task.should:: requires at least 1 argument.".
PASS 3 < 5 is true. PASS 3 < 5 is true.
PASS false is false. PASS false is false.
...@@ -37,7 +39,7 @@ PASS The message is truthful! ...@@ -37,7 +39,7 @@ PASS The message is truthful!
PASS Decoding audio data with no argument rejected correctly with TypeError: Failed to execute 'decodeAudioData' on 'BaseAudioContext': 1 argument required, but only 0 present.. PASS Decoding audio data with no argument rejected correctly with TypeError: Failed to execute 'decodeAudioData' on 'BaseAudioContext': 1 argument required, but only 0 present..
PASS Suspending OAC with no argument rejected correctly with TypeError. PASS Suspending OAC with no argument rejected correctly with TypeError.
PASS Start OAC rendering resolved correctly. PASS Start OAC rendering resolved correctly.
PASS < [basic] All assertions passed. (total 20 assertions) PASS < [basic] All assertions passed. (total 22 assertions)
PASS > [load-file-in-should] Test Audit.loadFileFromUrl() within |should| assertion. PASS > [load-file-in-should] Test Audit.loadFileFromUrl() within |should| assertion.
PASS Loading file within should().beResolved() resolved correctly. PASS Loading file within should().beResolved() resolved correctly.
PASS < [load-file-in-should] All assertions passed. (total 1 assertions) PASS < [load-file-in-should] All assertions passed. (total 1 assertions)
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
should(function () { var foo1 = 0; }, 'Setting foo1 to 0').notThrow(); should(function () { var foo1 = 0; }, 'Setting foo1 to 0').notThrow();
should(function () { var foo2 = bar; }).throw(); should(function () { var foo2 = bar; }).throw();
should(function () { var foo3 = bar; }).throw('ReferenceError'); should(function () { var foo3 = bar; }).throw('ReferenceError');
should(function () { var foo4 = bar; }).throw(null);
should(function () { var foo5 = bar; }).throw(undefined);
should(() => { should(); }, 'Calling should() with no argument') should(() => { should(); }, 'Calling should() with no argument')
.throw('Error'); .throw('Error');
should(3 < 5, '3 < 5').beTrue(); should(3 < 5, '3 < 5').beTrue();
......
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