This repository has been archived by the owner on Oct 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 170
/
Copy pathtest_coffeelint.coffee
54 lines (44 loc) · 1.61 KB
/
test_coffeelint.coffee
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
path = require 'path'
vows = require 'vows'
assert = require 'assert'
coffeelint = require path.join('..', 'lib', 'coffeelint')
vows.describe('coffeelint').addBatch({
"CoffeeLint's version number":
topic: coffeelint.VERSION
'exists': (version) ->
assert.isString(version)
"CoffeeLint's errors":
topic: () -> coffeelint.lint '''
a = () ->\t
1234
'''
'are sorted by line number': (errors) ->
assert.isArray(errors)
assert.lengthOf(errors, 2)
assert.equal(errors[1].lineNumber, 2)
assert.equal(errors[0].lineNumber, 1)
'Errors in the source':
topic:
'''
fruits = [orange, apple, banana]
switch 'a'
when in fruits
something
'''
'are reported': (source) ->
errors = coffeelint.lint(source)
assert.isArray(errors)
assert.lengthOf(errors, 1)
error = errors[0]
assert.equal(error.rule, 'coffeescript_error')
assert.equal(error.lineNumber, 3)
if error.message.indexOf('on line') isnt -1
m = "Error: Parse error on line 3: Unexpected 'RELATION'"
else if error.message.indexOf('SyntaxError:') isnt -1
m = 'SyntaxError: unexpected RELATION'
else
# CoffeeLint changed the format to be more complex. I don't
# think an exact match really needs to be verified.
return
assert.equal(error.message, m)
}).export(module)