Commit 29685537 authored by Sam Clegg's avatar Sam Clegg Committed by Commit Bot

Export `mjsunit.formatFailureText` which is needed by `test-async.js`

Without this the call to `formatFailureText` in `test-async.js`
fails but goes unnoticed since the promise change is rejects
which is not handled.  And d8 silently ignores the the unhandled
rejections.

Once `formatFailureText` was added it reveals a but where several
tests were expecting `.equal` to be a deepEquals.  Specifically:

test/mjsunit/es6/promise-all.js
test/mjsunit/harmony/async-generators-resume-return.js
test/mjsunit/harmony/async-generators-return.js
test/mjsunit/harmony/async-generators-yield.js

Making equals call `deepEquals` fixed that issue.

Change-Id: I350c7d916147eaa7cf873bdaf273aebbaaa833c5
Reviewed-on: https://chromium-review.googlesource.com/1236852
Commit-Queue: Sam Clegg <sbc@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56107}
parent 9ed4b965
......@@ -64,6 +64,9 @@ var assertNotSame;
// and the properties of non-Array objects).
var assertEquals;
// Deep equality predicate used by assertEquals.
var deepEquals;
// Expected and found values are not identical primitive values or functions
// or similarly structured objects (checking internal properties
// of, e.g., Number and Date objects, the elements of arrays
......@@ -183,6 +186,9 @@ var isTurboFanned;
// Monkey-patchable all-purpose failure handler.
var failWithMessage;
// Returns the formatted failure text. Used by test-async.js.
var formatFailureText;
// Returns a pretty-printed string representation of the passed value.
var prettyPrinted;
......@@ -297,7 +303,7 @@ var prettyPrinted;
throw new MjsUnitAssertionError(message);
}
function formatFailureText(expectedText, found, name_opt) {
formatFailureText = function(expectedText, found, name_opt) {
var message = "Fail" + "ure";
if (name_opt) {
// Fix this when we ditch the old test runner.
......@@ -335,7 +341,7 @@ var prettyPrinted;
}
function deepEquals(a, b) {
deepEquals = function deepEquals(a, b) {
if (a === b) {
// Check for -0.
if (a === 0) return (1 / a) === (1 / b);
......
......@@ -53,7 +53,7 @@ var testAsync;
equals(expected, found, name_opt) {
this.actualAsserts_++;
if (expected !== found) {
if (!deepEquals(expected, found)) {
this.fail(prettyPrinted(expected), found, name_opt);
}
}
......
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