forked from atom/language-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython-spec.coffee
More file actions
37 lines (26 loc) · 1.35 KB
/
Copy pathpython-spec.coffee
File metadata and controls
37 lines (26 loc) · 1.35 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
describe "Python grammar", ->
grammar = null
beforeEach ->
waitsForPromise ->
atom.packages.activatePackage("language-python")
runs ->
grammar = atom.syntax.grammarForScopeName("source.python")
it "parses the grammar", ->
expect(grammar).toBeDefined()
expect(grammar.scopeName).toBe "source.python"
it "tokenizes multi-line strings", ->
tokens = grammar.tokenizeLines('"1\\\n2"')
# Line 0
expect(tokens[0][0].value).toBe '"'
expect(tokens[0][0].scopes).toEqual ['source.python', 'string.quoted.double.single-line.python', 'punctuation.definition.string.begin.python']
expect(tokens[0][1].value).toBe '1'
expect(tokens[0][1].scopes).toEqual ['source.python', 'string.quoted.double.single-line.python']
expect(tokens[0][2].value).toBe '\\'
expect(tokens[0][2].scopes).toEqual ['source.python', 'string.quoted.double.single-line.python', 'constant.character.escape.newline.python']
expect(tokens[0][3]).not.toBeDefined()
# Line 1
expect(tokens[1][0].value).toBe '2'
expect(tokens[1][0].scopes).toEqual ['source.python', 'string.quoted.double.single-line.python']
expect(tokens[1][1].value).toBe '"'
expect(tokens[1][1].scopes).toEqual ['source.python', 'string.quoted.double.single-line.python', 'punctuation.definition.string.end.python']
expect(tokens[1][2]).not.toBeDefined()