-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMD4LeanTestDriver.lean
68 lines (52 loc) · 1.32 KB
/
MD4LeanTestDriver.lean
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
64
65
66
67
68
import MD4Lean
import MD4LeanTest.Parser
open MD4Lean.Test.Parser
/-!
# Rendering tests
-/
/-- info: some "<p>Hello <em>world</em></p>\n" -/
#guard_msgs in
#eval MD4Lean.renderHtml "Hello *world*"
/-!
# Parsing tests
Here, there is a `main` that is intended to be executed, as well as
run from the Lean frontend. This is to check that the library works in
both contexts.
-/
/--
Runs the parser tests.
With no arguments, the tests are run once to ensure they pass. With a
number as an argument, the tests are run that many times; this can be
helpful to ensure the absence of reference counting errors in the FFI
used by the parser.
-/
def main : List String → IO UInt32
| [] => do
let successes ← IO.mkRef 0
let failures ← IO.mkRef #[]
runTests successes failures 0
report successes failures
| [n] => do
match n.toNat? with
| none =>
IO.eprintln s!"Didn't understand '{n}' as a Nat"
return 1
| some k =>
let successes ← IO.mkRef 0
let failures ← IO.mkRef #[]
for i in [0:k] do
runTests successes failures i
report successes failures
| _ => do
IO.eprintln "Too many arguments"
return 2
/-!
Also ensure that the parser can be used from Lean itself
-/
/--
info: Succeeded after running 47 parses
---
info: 0
-/
#guard_msgs in
#eval main []