Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions test/harness/assert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
function assert(mustBeTrue, message) {
if (mustBeTrue === true) {
return;
}

if (message === undefined) {
message = 'Expected true but got ' + String(truthy);
}
$ERROR(message);
}

assert._isSameValue = function (a, b) {
if (a === b) {
// Handle +/-0 vs. -/+0
return a !== 0 || 1 / a === 1 / b;
}

// Handle NaN vs. NaN
return a !== a && b !== b;
};

assert.sameValue = function (actual, expected, message) {
if (assert._isSameValue(actual, expected)) {
return;
}

if (message === undefined) {
message = 'Expected SameValue(' + String(actual) + ', ' + String(expected) + ') to be true';
}
$ERROR(message);
};

assert.notSameValue = function (actual, unexpected, message) {
if (!assert._isSameValue(actual, unexpected)) {
return;
}

if (message === undefined) {
message = 'Expected SameValue(' + String(actual) + ', ' + String(unexpected) + ') to be false';
}
$ERROR(message);
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ description: thisArg should be bound to this if provided
var globalThis = this;

[1].find(function () {
if (this !== Array) {
$ERROR('#1: this !== Array');
}
if (this === globalThis) {
$ERROR('#2: this === globalThis. Should be Array');
}
assert.sameValue(this, Array, 'this should equal Array');
assert.notSameValue(this, globalThis, 'this should not equal globalThis');
}, Array);