shift-interpreter
Version:
Shift-interpreter is an experimental JavaScript meta-interpreter useful for reverse engineering and analysis. One notable difference from other projects is that shift-interpreter retains state over an entire script but can be fed expressions and statement
39 lines • 1.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("../util");
const operators = [
'==',
'!=',
'===',
'!==',
'<',
'<=',
'>',
'>=',
'<<',
'>>',
'>>>',
'+',
'-',
'*',
'/',
'%',
'**',
',',
'&&',
',',
'^',
'&',
];
// const specialOps = ['in' , 'instanceof'];
describe('BinaryExpressions', () => {
it('should evaluate operators the same as the host environment', () => {
const sample = [2, 120, 1981, '2', 'hi', NaN, true, false, 1 / 0];
const results = operators.flatMap(op => sample.flatMap(l => sample.map(r => util_1.compare(`${JSON.stringify(l)} ${op} ${JSON.stringify(r)}`))));
results.forEach(result => util_1.assertResult(result));
});
it('should retain shortcircuit behavior', () => {
util_1.assertResult(util_1.compare(`typeof x == 'string' && nonexistant()`));
});
});
//# sourceMappingURL=binary-expressions.test.js.map