scratch-vm/test/fixtures/test-compare.js

16 lines
582 B
JavaScript
Raw Normal View History

2018-08-31 15:38:06 -04:00
const testCompare = (t, lhs, op, rhs, message) => {
const details = `Expected: ${lhs} ${op} ${rhs}`;
const extra = {details};
switch (op) {
case '<': return t.ok(lhs < rhs, message, extra);
case '<=': return t.ok(lhs <= rhs, message, extra);
case '===': return t.ok(lhs === rhs, message, extra);
case '!==': return t.ok(lhs !== rhs, message, extra);
case '>=': return t.ok(lhs >= rhs, message, extra);
case '>': return t.ok(lhs > rhs, message, extra);
default: return t.fail(`Unrecognized op: ${op}`);
}
};
module.exports = testCompare;