compiler-test.js
972 Bytes
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
/* global describe, it */
var compile = require('../lib/compiler')
var assert = require('assert')
var util = require('../lib/util')
var tests
tests = {
'a': {a: {type: 'object'}},
'a,b,c': {
a: {type: 'object'},
b: {type: 'object'},
c: {type: 'object'}
},
'a/*/c': {
a: {type: 'object', properties: {
'*': {type: 'object', properties: {
c: {type: 'object'}
}}
}}
},
'a,b(d/*/g,b),c': {
a: {type: 'object'},
b: {type: 'array', properties: {
d: {type: 'object', properties: {
'*': {type: 'object', properties: {
g: {type: 'object'}
}}
}},
b: {type: 'object'}
}},
c: {type: 'object'}
}
}
describe('compiler', function () {
for (var name in tests) {
if (!util.has(tests, name)) continue
(function (name, test) {
it('should compile ' + name, function () {
assert.deepEqual(compile(name), test)
})
}(name, tests[name]))
}
})