44 lines
1001 B
JavaScript
44 lines
1001 B
JavaScript
import { expect } from 'chai'
|
|
import fs from 'node:fs/promises'
|
|
import { useDocument } from '@terrace/core'
|
|
import { createReadlineReader } from '@terrace/core/readers/node-readline'
|
|
|
|
async function loadTests(path) {
|
|
const { next, level, head, tail, line, match } = useDocument(createReadlineReader(path))
|
|
|
|
const tests = {}
|
|
|
|
while (await next()) {
|
|
if (!head() || match('#schema')) continue
|
|
const rootLevel = level()
|
|
|
|
const test = tests[tail().trim()] = { input: [], output: [] }
|
|
|
|
while (await next(rootLevel)) {
|
|
const testLevel = level()
|
|
if (match('input')) {
|
|
while (await next(testLevel)) {
|
|
test.input.push(line(testLevel))
|
|
}
|
|
}
|
|
|
|
if (match('output')) {
|
|
while (await next(testLevel)) {
|
|
test.output.push(line(testLevel))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
return tests
|
|
}
|
|
|
|
it('Runs a basic test', async () => {
|
|
const tests = await loadTests('./tests.tce', 'utf-8')
|
|
|
|
console.log(tests)
|
|
|
|
expect(1).to.equal(1)
|
|
})
|