-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
37 lines (29 loc) · 884 Bytes
/
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
import util from 'util'
import {detailedDiff} from 'deep-object-diff'
import flexion from './'
import wordRef from './wordRef'
const fancyLog = whatever => console.log(util.inspect(whatever, {
depth: Infinity,
compact: false,
colors: true
}))
process.stdin.setEncoding('utf8')
process.stdin.on('readable', async () => {
process.stdin.resume()
const input = process.stdin.read()
const [query, dontRunTest] = input.split(' ')
if(input !== null){
const result = flexion(query)
fancyLog(result)
if(!dontRunTest){
const wordRefResult = await wordRef(query).catch(e => console.error(e))
const diff = detailedDiff(result, wordRefResult)
const test = !Object.keys(diff.updated).length
if(!test) fancyLog(diff)
console.log(test ? 'PASSED' : 'FAILED')
}
}
})
process.stdin.on('end', () => {
process.stdout.write('end')
})