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
34 lines • 1.15 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const mocha_1 = require("mocha");
const util_1 = require("../util");
mocha_1.describe('new', () => {
it('should instantiate functions and retain prototype chain', () => {
util_1.assertResult(util_1.compare(`
function d() {}
d.prototype.run = function () {return "expected"};
d.prototype.run();
const a = new d();
a.run();
`));
});
it('should return the return value for an instantiated function if the fn returns', () => {
util_1.assertResult(util_1.compare(`
function d() { return { run() {return 'this one'}}; }
d.prototype.run = function () {return "not this one"};
d.prototype.run();
const a = new d();
a.run();
`));
});
it('should still return the "this" if a primitive is returned', () => {
util_1.assertResult(util_1.compare(`
function d() { return 2; }
d.prototype.run = function () {return "expected"};
d.prototype.run();
const a = new d();
a.run();
`));
});
});
//# sourceMappingURL=new-expression.test.js.map