aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-07-15 15:14:40 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-07-15 15:14:40 -0400
commitf989e80fb38beea9c803d34ceee6f40bdbf0269a (patch)
tree8e17c58f01134a5f858299f88b043f4b1f94e030
parent5e81613ac137c5641675ceb792ca105d345d98c6 (diff)
Move markdown tester into a separate file
-rw-r--r--md.bqn27
-rwxr-xr-xtest/markdown.bqn24
2 files changed, 26 insertions, 25 deletions
diff --git a/md.bqn b/md.bqn
index 8d8652f5..5576ba12 100644
--- a/md.bqn
+++ b/md.bqn
@@ -583,31 +583,6 @@ Markdown ← {filename𝕊𝕩:
################################
-# Testing
-# Uses the test cases at https://spec.commonmark.org/0.29/spec.json
-# since Github doesn't seem to have published theirs
-TestSections ← {
- tests ← ¯2 ↓˘ 8⊸(÷˜⟜≠∾⊣)⊸⥊ 2↓•file.Lines"spec.json"
- tests ↩ ((⊑2+⊐⟜':')¨∘⊏ ((-','=¯1⊑⊢)↓↓)¨⎉1 ⊢) tests
- testSection ← (1↓¯1↓⊢)¨ 5⊏˘tests
- UnEscape ← {
- EscapeChar ← { ("\""tn"⊐𝕩) ⊏ "\"""∾@+9‿10 }
- esc ← IsEscaped 𝕩
- (¬«esc) / EscapeChar⌾(esc⊸/) 𝕩
- }
- RunTest ← {
- in‿exp ← UnEscape∘(1↓¯1↓⊢)¨2↑𝕩
- out ← 0 Markdown (@+10) ((⊢-˜¬×+`)∘=⊔⊢) in
- ⟨exp≡out,in,exp,out,2⊑𝕩⟩
- }
-
- ignore ← (2 ⊏˘ tests) ∊ ⟨"47","85"⟩
- res ← 1 ↓˘ (¬⊏˘)⊸/ RunTest˘ tests /˜ ignore < testSection ∊ 𝕩
- res
-}
-
-
-################################
# Syntax highlighting
# Characters in identifiers. These are also used in ProcCode to detect
@@ -766,3 +741,5 @@ ConvertFile ← {
}
ConvertFile¨ •args
+
+Markdown # Used by tester test/commonmark.bqn
diff --git a/test/markdown.bqn b/test/markdown.bqn
new file mode 100755
index 00000000..eefcc63c
--- /dev/null
+++ b/test/markdown.bqn
@@ -0,0 +1,24 @@
+#! /usr/bin/env bqn
+
+# Tests for the markdown parser
+# Uses the test cases at https://spec.commonmark.org/0.29/spec.json
+# since Github doesn't seem to have published theirs
+markdown ← •Import "../md.bqn"
+
+tests ← ¯2 ↓˘ 8⊸(÷˜⟜≠∾⊣)⊸⥊ 2↓•file.Lines"spec.json"
+tests ↩ ((⊑2+⊐⟜':')¨∘⊏ ((-','=¯1⊑⊢)↓↓)¨⎉1 ⊢) tests
+testSection ← (1↓¯1↓⊢)¨ 5⊏˘tests
+UnEscape ← {
+ EscapeChar ← { ("\""tn"⊐𝕩) ⊏ "\"""∾@+9‿10 }
+ esc ← » <` 𝕩='\'
+ (¬«esc) / EscapeChar⌾(esc⊸/) 𝕩
+}
+RunTest ← {
+ in‿exp ← UnEscape∘(1↓¯1↓⊢)¨2↑𝕩
+ out ← 0 Markdown (@+10) ((⊢-˜¬×+`)∘=⊔⊢) in
+ ⟨exp≡out,in,exp,out,2⊑𝕩⟩
+}
+
+ignore ← (2 ⊏˘ tests) ∊ ⟨"47","85"⟩
+res ← 1 ↓˘ (¬⊏˘)⊸/ RunTest˘ tests /˜ ignore < testSection ∊ •args
+•Show res