-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.js
36 lines (28 loc) · 816 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const Qjsc = require('./index');
const qjsc = new Qjsc();
describe('qjsc', () => {
it('throw error when empty arguments', () => {
expect(() => qjsc.compile()).toThrowError('1st arguments should be string.');
});
it('throw error when js syntax not correct', () => {
const code = `
function f() {
console.log(111;
`;
expect(() => qjsc.compile(code)).toThrowError();
});
it('return bytecode binary', () => {
const code = `
function f() { return 1 + '1234'; }
f();
`;
let buffer = qjsc.compile(code);
expect(qjsc._evalByteCode(buffer)).toBe('11234');
});
it('support 20210327', () => {
expect(qjsc.version).toBe('20210327');
});
it('get all supported version', () => {
expect(qjsc.getSupportedVersions()).toEqual(['20210327']);
});
});