babeler/test/update-expression.js

16 lines
515 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('evaluates UpdateExpression', () => {
expect(new Sandbox(parse('a++'), {a: 1}).next().value)
.to.deep.include({value: 1});
expect(new Sandbox(parse('++a'), {a: 1}).next().value)
.to.deep.include({value: 2});
expect(new Sandbox(parse('a--'), {a: 1}).next().value)
.to.deep.include({value: 1});
expect(new Sandbox(parse('--a'), {a: 1}).next().value)
.to.deep.include({value: 0});
});