scratch-vm/test/fixtures/test-compare.js
Christopher Willis-Ford 33e0197ad5 Add tests for TokenBucket
2018-09-13 17:05:00 -04:00

15 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;