Skip to content
Snippets Groups Projects
Commit 4bb8c027 authored by Domenic Denicola's avatar Domenic Denicola
Browse files

Add initial assert helpers

Closes #110
parent bbeafbd3
No related branches found
No related tags found
No related merge requests found
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);
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment