mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 22:42:27 -05:00
16 lines
582 B
JavaScript
16 lines
582 B
JavaScript
|
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;
|