Fix obvious bug.
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
#schema test
|
||||
|
||||
input
|
||||
key value
|
||||
|
||||
output
|
||||
level: 0 | head: key | tail: value | line: key value
|
||||
@@ -3,34 +3,41 @@ import fs from 'node:fs/promises'
|
||||
import { useDocument } from '@terrace/core'
|
||||
import { createReadlineReader } from '@terrace/core/readers/node-readline'
|
||||
|
||||
async function loadTest(path) {
|
||||
async function loadTests(path) {
|
||||
const { next, level, head, tail, line, match } = useDocument(createReadlineReader(path))
|
||||
|
||||
const test = { input: [], output: [] }
|
||||
const tests = {}
|
||||
|
||||
while (await next()) {
|
||||
if (match('input')) {
|
||||
const rootLevel = level()
|
||||
while (await next(rootLevel)) {
|
||||
test.input.push(line(rootLevel))
|
||||
}
|
||||
}
|
||||
if (!head() || match('#schema')) continue
|
||||
const rootLevel = level()
|
||||
|
||||
if (match('output')) {
|
||||
const rootLevel = level()
|
||||
while (await next(rootLevel)) {
|
||||
test.input.push(line(rootLevel))
|
||||
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 { input: test.input.join('\n'), output: test.output.join('\n') }
|
||||
|
||||
return tests
|
||||
}
|
||||
|
||||
it('Runs a basic test', async () => {
|
||||
const { input, output } = await loadTest('./basic.test.tce', 'utf-8')
|
||||
const tests = await loadTests('./tests.tce', 'utf-8')
|
||||
|
||||
console.log(input)
|
||||
console.log(tests)
|
||||
|
||||
expect(1).to.equal(1)
|
||||
})
|
||||
|
||||
8
test/tests.tce
Normal file
8
test/tests.tce
Normal file
@@ -0,0 +1,8 @@
|
||||
#schema test
|
||||
|
||||
test Basic
|
||||
input
|
||||
key value
|
||||
|
||||
output
|
||||
level: 0 | head: key | tail: value | line: key value
|
||||
Reference in New Issue
Block a user