forked from rokucommunity/brighterscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStop.spec.ts
More file actions
59 lines (51 loc) · 1.88 KB
/
Stop.spec.ts
File metadata and controls
59 lines (51 loc) · 1.88 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { expect } from '../../../chai-config.spec';
import { Parser } from '../../Parser';
import { Lexer } from '../../../lexer/Lexer';
import { TokenKind } from '../../../lexer/TokenKind';
import { EOF, token } from '../Parser.spec';
describe('stop statement', () => {
it('cannot be used as a local variable', () => {
let { statements, diagnostics } = Parser.parse([
token(TokenKind.Stop, 'stop'),
token(TokenKind.Equal, '='),
token(TokenKind.True, 'true'),
EOF
]);
//should be an error
expect(diagnostics).to.be.length.greaterThan(0);
expect(statements).to.exist;
expect(statements).not.to.be.null;
});
it('is valid as a statement', () => {
let { diagnostics } = Parser.parse([token(TokenKind.Stop, 'stop'), EOF]);
expect(diagnostics[0]).to.be.undefined;
});
it('can be used as an object property', () => {
let { tokens } = Lexer.scan(`
sub Main()
theObject = {
stop: false
}
theObject.stop = true
end sub
`);
let { diagnostics } = Parser.parse(tokens);
expect(diagnostics.length).to.equal(0);
});
it('supports @stop', () => {
let { diagnostics } = Parser.parse([token(TokenKind.AtStop, '@stop'), EOF]);
expect(diagnostics[0]).to.be.undefined;
});
it('supports @STOP', () => {
let { diagnostics } = Parser.parse([token(TokenKind.AtStop, '@STOP'), EOF]);
expect(diagnostics[0]).to.be.undefined;
});
it('lexer recognizes @stop', () => {
let { tokens } = Lexer.scan('@stop');
expect(tokens[0].kind).to.equal(TokenKind.AtStop);
});
it('lexer recognizes @STOP', () => {
let { tokens } = Lexer.scan('@STOP');
expect(tokens[0].kind).to.equal(TokenKind.AtStop);
});
});