-
-
Notifications
You must be signed in to change notification settings - Fork 230
/
negative.test.js
31 lines (27 loc) · 960 Bytes
/
negative.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
/* globals describe, it */
import { assert } from 'chai';
import * as verifier from './util/verifier';
describe('negative tests', () => {
it('should barf on junk code', () => {
const v = verifier.create('output = args[0] : 1 : 2;', { quiet: true });
const err = v.compileError();
assert.ok(err);
assert.ok(err.message.match(/Unexpected token/));
});
it('should barf on non-string code', () => {
const v = verifier.create({}, { quiet: true });
const err = v.compileError();
assert.ok(err);
assert.ok(err.message.match(/must be a string/));
});
it('should barf on mainline returns with no auto-wrap', () => {
const v = verifier.create(
'return 10;',
{ quiet: true },
{ autoWrap: false }
);
const err = v.compileError();
assert.ok(err);
assert.ok(err.message.match(/'return' outside/));
});
});