Commit bdf7fea4 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[test] Fix {assertNotSame} in mjsunit test harness.

This assertion was borked, as it accepted obviously "same" values like
the same object. This fixes the predicate by switching both assertSame
and assertNotSame to use {Object.is} underneath. It also adds a new
respective regression test (gotta test the tester).

R=ahaas@chromium.org
TEST=message/mjsunit/fail/assert_not_same

Change-Id: I6ba20c4b8b96a736ab924715b1cad78f2f43a120
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1687541Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62512}
parent 9056c1f8
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
load("test/mjsunit/mjsunit.js");
assertNotSame(1, 1);
test/mjsunit/mjsunit.js:{NUMBER}: Failure: expected <not same as 1> found <1>
Stack: MjsUnitAssertionError
at assertNotSame *mjsunit.js {NUMBER}:{NUMBER}
at *%(basename)s 7:1
throw new MjsUnitAssertionError(message);
^
MjsUnitAssertionError
at assertNotSame *mjsunit.js {NUMBER}:{NUMBER}
at *%(basename)s 7:1
......@@ -390,25 +390,13 @@ var prettyPrinted;
}
assertSame = function assertSame(expected, found, name_opt) {
// TODO(mstarzinger): We should think about using Harmony's egal operator
// or the function equivalent Object.is() here.
if (found === expected) {
if (expected !== 0 || (1 / expected) === (1 / found)) return;
} else if ((expected !== expected) && (found !== found)) {
return;
}
if (Object.is(expected, found)) return;
fail(prettyPrinted(expected), found, name_opt);
};
assertNotSame = function assertNotSame(expected, found, name_opt) {
// TODO(mstarzinger): We should think about using Harmony's egal operator
// or the function equivalent Object.is() here.
if (found !== expected) {
if (expected === 0 || (1 / expected) !== (1 / found)) return;
} else if (!((expected !== expected) && (found !== found))) {
return;
}
fail(prettyPrinted(expected), found, name_opt);
if (!Object.is(expected, found)) return;
fail("not same as " + prettyPrinted(expected), found, name_opt);
}
assertEquals = function assertEquals(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