babeler/test/scope.js

18 lines
526 B
JavaScript
Raw Normal View History

2022-02-27 07:32:34 -06:00
import {parse} from '@babel/parser';
import {expect} from 'chai';
import Sandbox from '../src/sandbox';
it('scopes BlockStatement', () => {
const sandbox = new Sandbox(parse('if (true) { const foo = 69; foo; } foo;'));
expect(sandbox.next().value)
.to.deep.include({value: 69});
expect(sandbox.next().value)
.to.deep.include({value: undefined});
});
it('scopes ForStatement', () => {
expect(new Sandbox(parse('for (let i = 0; i < 5; ++i) {} i;')).next().value)
.to.deep.include({value: undefined});
});