UNPKG

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

23 lines 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const util_1 = require("../util"); const operators = ['+=', '-=', '*=', '/=', '%=', '**=', '<<=', '>>=', '>>>=', '^=', '&=']; // const specialOps = ['in' , 'instanceof']; describe('CompoundAssignment', () => { it('should assign to identifiers', () => { 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(`let b = ${JSON.stringify(l)}; b ${op} ${JSON.stringify(r)}`)))); results.forEach(result => util_1.assertResult(result)); }); it('should assign to static members', () => { 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(`let b = {a:${JSON.stringify(l)}}; b.a ${op} ${JSON.stringify(r)}`)))); results.forEach(result => util_1.assertResult(result)); }); it('should assign to computed members', () => { 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(`let b = {["a"]:${JSON.stringify(l)}}; b["a"] ${op} ${JSON.stringify(r)}`)))); results.forEach(result => util_1.assertResult(result)); }); }); //# sourceMappingURL=compound-assignments.test.js.map