-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
40 lines (32 loc) · 938 Bytes
/
index.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
38
39
40
import test from "ava"
import * as fs from "node:fs"
import { resolve } from "node:path"
import { parser } from "../index.js"
function traverse(input, t) {
const tree = parser.parse(input)
const cursor = tree.cursor()
do {
if (cursor.node.type.isError) {
const { from, to } = cursor
const value = JSON.stringify(input.slice(from, to))
t.fail(`error from ${from} to ${to}: ${value}`)
}
} while (cursor.next())
t.pass()
}
test("example.tasl", (t) => {
const input = fs.readFileSync(resolve("test", "example.tasl"), "utf-8")
traverse(input, t)
})
test("simple.tasl", (t) => {
const input = fs.readFileSync(resolve("test", "simple.tasl"), "utf-8")
traverse(input, t)
})
test("rdf.tasl", (t) => {
const input = fs.readFileSync(resolve("test", "rdf.tasl"), "utf-8")
traverse(input, t)
})
test("schema.tasl", (t) => {
const input = fs.readFileSync(resolve("test", "schema.tasl"), "utf-8")
traverse(input, t)
})