Skip to content

Commit

Permalink
More tests for internal vars in instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Dec 10, 2023
1 parent 9a8b19b commit 0dea35c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/with.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,40 @@ describe('with statements', () => {
}
});

itSerializes('`livepack_scopeId`', {
in: `
const x = 123;
with ({livepack_scopeId_2: 1}) {
module.exports = () => x;
}
`,
out: '(x=>a=>{with(a)return()=>x})(123)({livepack_scopeId_2:1})',
validate(fn, {transpiled}) {
expect(fn).toBeFunction();
expect(fn()).toBe(123);

// Check internal var matches the one being tested for
expect(transpiled.split('\n')[0])
.toInclude(';const livepack_scopeId_2 = livepack_getScopeId();');
}
});

itSerializes('`livepack_temp` for `with` object', {
in: `
with ({livepack_temp_6: 1, x: 2}) {
module.exports = () => x;
}
`,
out: '(a=>{with(a)return()=>x})({livepack_temp_6:1,x:2})',
validate(fn, {transpiled}) {
expect(fn).toBeFunction();
expect(fn()).toBe(2);

// Check internal var match the one being tested for
expect(transpiled.split('\n')[0]).toInclude(';let livepack_temp_6;');
}
});

itSerializes('`livepack_temp` for class `super`', {
in: `
class S {
Expand Down

0 comments on commit 0dea35c

Please sign in to comment.