-
Notifications
You must be signed in to change notification settings - Fork 10
/
test.js
51 lines (44 loc) · 1.1 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var assert = require('assert')
var examples = require('./examples.json')
var satisfies = require('./')
var failed = false
function write (string) { process.stdout.write(string) }
function label (example) {
write('satisfies(' + JSON.stringify(example[0]) + ', ' + JSON.stringify(example[1]) + ')')
}
examples.returnTrue.forEach(function (example) {
label(example)
try {
assert(satisfies(example[0], example[1]) === true)
} catch (error) {
failed = true
write(' did not return true\n')
return
}
write(' returned true\n')
})
// False Examples
examples.returnFalse.forEach(function (example) {
label(example)
try {
assert(satisfies(example[0], example[1]) === false)
} catch (error) {
failed = true
write(' did not return false\n')
return
}
write(' returned false\n')
})
// Invalid License Arrays
examples.throwErrors.forEach(function (example) {
label(example)
try {
satisfies(example[0], example[1])
} catch (error) {
write(' threw an exception\n')
return
}
failed = true
write(' did not throw an exception\n')
})
process.exit(failed ? 1 : 0)