forked from LeaVerou/parsel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
63 lines (54 loc) · 1.54 KB
/
test.html
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Parsel Tests</title>
<link rel="stylesheet" href="https://test.mavo.io/style.css" />
<style>
td {
white-space: pre;
font-family: Consolas, Monaco, monospace;
}
</style>
</head>
<body>
<h1>Parsel Tests</h1>
<section>
<h1>Tokens</h1>
<table class="reftest" data-test="testTokenize" data-columns="3">
<tr>
<td>#foo</td>
<td>[{"type":"id", "content":"#foo", "name":"foo", "pos":[0,4]}]</td>
</tr>
</table>
</section>
<section>
<h1>AST</h1>
<table class="reftest" data-test="testAST" data-columns="3">
<tr>
<td>#foo</td>
<td>{"type":"id", "content":"#foo", "name":"foo", "pos":[0,4]}</td>
</tr>
</table>
</section>
<script src="https://cdnjs.cloudflare.com/ajax/libs/blissfuljs/1.0.4/bliss.min.js"></script>
<script src="https://test.mavo.io/test.js"></script>
<script type="module">
import * as parsel from "./parsel.js";
window.testTokenize = function(test, result, expected) {
console.log(arguments)
let tokens = parsel.tokenize(test.textContent);
let serialized = JSON.stringify(tokens, null, "\t");
result.textContent = serialized;
return Test.equals(JSON.stringify(JSON.parse(expected.textContent), null, "\t"), serialized);
}
window.testAST = function(test, result, expected) {
console.log(arguments)
let ast = parsel.parse(test.textContent);
let serialized = JSON.stringify(ast, null, "\t");
result.textContent = serialized;
return Test.equals(JSON.stringify(JSON.parse(expected.textContent), null, "\t"), serialized);
}
</script>
</body>
</html>