chore: test scopes
This commit is contained in:
parent
c7cb1b6876
commit
1a908bc0af
|
@ -32,6 +32,30 @@ test('declares variables', async () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('scopes variables', async () => {
|
||||
const sandbox = new Sandbox(
|
||||
await parse(`
|
||||
const result = [];
|
||||
const scalar = 1;
|
||||
result.push(scalar);
|
||||
{
|
||||
const scalar = 2;
|
||||
result.push(scalar);
|
||||
}
|
||||
result.push(scalar);
|
||||
`),
|
||||
);
|
||||
let result;
|
||||
do {
|
||||
result = sandbox.step();
|
||||
if (result.value?.async) {
|
||||
await result.value.async;
|
||||
}
|
||||
} while (!result.done);
|
||||
expect(sandbox.context.result)
|
||||
.to.deep.equal([1, 2, 1]);
|
||||
});
|
||||
|
||||
test('destructures variables', async () => {
|
||||
const sandbox = new Sandbox(
|
||||
await parse(`
|
||||
|
|
Loading…
Reference in New Issue
Block a user