-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.test.js
More file actions
30 lines (24 loc) · 796 Bytes
/
Copy pathparser.test.js
File metadata and controls
30 lines (24 loc) · 796 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
const { parse, parseTree, tokenize, tokens } = require ('../src')
const log = console.log.bind (console)
// Quick test
var samples = require ('./samples')
samples = ['{ width: 10px 2 10% 3 }']
samples = ['@media { booo } abcd @bd <!-- { width: 10px 2 10% 3 --> }']
samples = ['@page { margin:1cm; @top-center { color:red; } }']
// log(...parse('1px solid red, foo', 'DECL_VALUE'))
// log(...parseTree('1px solid red, foo', 'DECL_VALUE'))
samples.forEach (sample => {
log (sample)
let t = parse (sample)
log (Array.from (t), sample)
try {
log (JSON.stringify (parseTree (sample), fn, 2))
} catch (e) { log (e) }
})
function fn (k, o) {
let r = o
if (!Array.isArray (o) && typeof o === 'object') {
return Object.assign ({ type: o.constructor.name }, r)
}
return r
}