Newer
Older
minerva / Userland / Libraries / LibJS / Tests / regress / bogus-program-counter.js
@minerva minerva on 13 Jul 582 bytes Initial commit
test("Don't crash when throwing exception inside a callee smaller than the caller", () => {
    function make() {
        let o = {};
        Object.defineProperty(o, "go", {
            get: function () {
                return doesNotExist;
            },
        });
        return o;
    }

    // Some nonsense to make sure this function has a longer bytecode than the throwing getter.
    function x() {
        return 3;
    }
    function b() {}
    b(x() + x() + x());

    expect(() => make().go()).toThrowWithMessage(ReferenceError, "'doesNotExist' is not defined");
});