Add tests Also fix up the patterns in light of said tests & code review.
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
diff --git a/components/prism-tap.js b/components/prism-tap.js
index 97bef15..80e5d3e 100644
--- a/components/prism-tap.js
+++ b/components/prism-tap.js
@@ -1,18 +1,18 @@
Prism.languages.tap = {
- pass: /(^|\n)( )*ok[^#\{\n]*/,
- fail: /(^|\n)( )*not ok[^#\{\n]*/,
- pragma: /(^|\n)( )*pragma ([+-])([a-z]+)(\n|$)/,
- bailout: /(^|\n)( )*bail out!(.*)(\n|$)/i,
- version: /(^|\n)( )*TAP version ([0-9]+)(\n|$)/i,
- plan: /(^|\n)( )*([0-9]+)\.\.([0-9]+)( +#[^\n]*)?(\n|$)/m,
+ fail: /not ok[^#{\n\r]*/,
+ pass: /ok[^#{\n\r]*/,
+ pragma: /pragma [+-][a-z]+/,
+ bailout: /bail out!.*/i,
+ version: /TAP version \d+/i,
+ plan: /\d+\.\.\d+(?: +#.*)?/,
subtest: {
- pattern: /(^|\n)( )*# Subtest(?:: (.*))?(\n|$)/,
+ pattern: /# Subtest(?:: .*)?/,
greedy: true
},
punctuation: /[{}]/,
- 'comment': /#.*/,
+ directive: /#.*/,
yamlish: {
- pattern: /(^|\n)(( )*( ))---\n(.*?\n)+\2\.\.\.(\n|$)/,
+ pattern: /(^[^\S\r\n]*)---(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?[^\S\r\n]*\.\.\.$/m,
lookbehind: true,
inside: Prism.languages.yaml,
alias: 'language-yaml'
diff --git a/components/prism-tap.min.js b/components/prism-tap.min.js
index c563148..4f14d9b 100644
--- a/components/prism-tap.min.js
+++ b/components/prism-tap.min.js
@@ -1 +1 @@
-Prism.languages.tap={pass:/(^|\n)( )*ok[^#\{\n]*/,fail:/(^|\n)( )*not ok[^#\{\n]*/,pragma:/(^|\n)( )*pragma ([+-])([a-z]+)(\n|$)/,bailout:/(^|\n)( )*bail out!(.*)(\n|$)/i,version:/(^|\n)( )*TAP version ([0-9]+)(\n|$)/i,plan:/(^|\n)( )*([0-9]+)\.\.([0-9]+)( +#[^\n]*)?(\n|$)/m,subtest:{pattern:/(^|\n)( )*# Subtest(?:: (.*))?(\n|$)/,greedy:!0},punctuation:/[{}]/,comment:/#.*/,yamlish:{pattern:/(^|\n)(( )*( ))---\n(.*?\n)+\2\.\.\.(\n|$)/,lookbehind:!0,inside:Prism.languages.yaml,alias:"language-yaml"}};
\ No newline at end of file
+Prism.languages.tap={fail:/not ok[^#{\n\r]*/,pass:/ok[^#{\n\r]*/,pragma:/pragma [+-][a-z]+/,bailout:/bail out!.*/i,version:/TAP version \d+/i,plan:/\d+\.\.\d+(?: +#.*)?/,subtest:{pattern:/# Subtest(?:: .*)?/,greedy:!0},punctuation:/[{}]/,directive:/#.*/,yamlish:{pattern:/(^[^\S\r\n]*)---(?:\r\n?|\n)(?:.*(?:\r\n?|\n))*?[^\S\r\n]*\.\.\.$/m,lookbehind:!0,inside:Prism.languages.yaml,alias:"language-yaml"}};
\ No newline at end of file
diff --git a/tests/languages/tap/bail_out_feature.test b/tests/languages/tap/bail_out_feature.test
new file mode 100644
index 0000000..eba8164
--- /dev/null
+++ b/tests/languages/tap/bail_out_feature.test
@@ -0,0 +1,13 @@
+Bail out! Couldn't connect to database.
+bail out! Failed to call API.
+
+----------------------------------------------------
+
+[
+ ["bailout", "Bail out! Couldn't connect to database."],
+ ["bailout", "bail out! Failed to call API."]
+]
+
+----------------------------------------------------
+
+Checks bail out
diff --git a/tests/languages/tap/directive_feature.test b/tests/languages/tap/directive_feature.test
new file mode 100644
index 0000000..5a3ff91
--- /dev/null
+++ b/tests/languages/tap/directive_feature.test
@@ -0,0 +1,15 @@
+ok # SKIP test not written
+ok 42 this is the description # TODO write test
+
+----------------------------------------------------
+
+[
+ ["pass", "ok " ],
+ ["directive", "# SKIP test not written"],
+ ["pass", "ok 42 this is the description "],
+ ["directive", "# TODO write test"]
+]
+
+----------------------------------------------------
+
+Checks directives
diff --git a/tests/languages/tap/pass_fail_feature.test b/tests/languages/tap/pass_fail_feature.test
new file mode 100644
index 0000000..d078299
--- /dev/null
+++ b/tests/languages/tap/pass_fail_feature.test
@@ -0,0 +1,17 @@
+not ok
+not ok 42 this is the description of the test
+ok
+ok 42 this is the description of the test
+
+----------------------------------------------------
+
+[
+ ["fail", "not ok" ],
+ ["fail", "not ok 42 this is the description of the test"],
+ ["pass", "ok" ],
+ ["pass", "ok 42 this is the description of the test"]
+]
+
+----------------------------------------------------
+
+Checks test pass & fail together correctly
diff --git a/tests/languages/tap/plan_feature.test b/tests/languages/tap/plan_feature.test
new file mode 100644
index 0000000..8bdcd4e
--- /dev/null
+++ b/tests/languages/tap/plan_feature.test
@@ -0,0 +1,13 @@
+1..10
+1..10 # directive
+
+----------------------------------------------------
+
+[
+ ["plan", "1..10" ],
+ ["plan", "1..10 # directive" ]
+]
+
+----------------------------------------------------
+
+Checks TAP plan
diff --git a/tests/languages/tap/pragma_feature.test b/tests/languages/tap/pragma_feature.test
new file mode 100644
index 0000000..7775f2e
--- /dev/null
+++ b/tests/languages/tap/pragma_feature.test
@@ -0,0 +1,13 @@
+pragma +strict
+pragma -strict
+
+----------------------------------------------------
+
+[
+ ["pragma", "pragma +strict"],
+ ["pragma", "pragma -strict"]
+]
+
+----------------------------------------------------
+
+Checks pragma
diff --git a/tests/languages/tap/version_feature.test b/tests/languages/tap/version_feature.test
new file mode 100644
index 0000000..600bccc
--- /dev/null
+++ b/tests/languages/tap/version_feature.test
@@ -0,0 +1,11 @@
+TAP version 13
+
+----------------------------------------------------
+
+[
+ ["version", "TAP version 13" ]
+]
+
+----------------------------------------------------
+
+Checks TAP version
diff --git a/tests/languages/tap/yamlish_feature.test b/tests/languages/tap/yamlish_feature.test
new file mode 100644
index 0000000..be4a19e
--- /dev/null
+++ b/tests/languages/tap/yamlish_feature.test
@@ -0,0 +1,50 @@
+ok
+ ---
+ message: "Failed with error 'hostname peebles.example.com not found'"
+ severity: fail
+ data:
+ got:
+ hostname: 'peebles.example.com'
+ address: ~
+ expected:
+ hostname: 'peebles.example.com'
+ address: '85.193.201.85'
+ ...
+
+----------------------------------------------------
+
+[
+ ["pass", "ok"],
+ ["yamlish", [
+ ["punctuation", "---"],
+ ["key", "message"],
+ ["punctuation", ":"],
+ ["string", "\"Failed with error 'hostname peebles.example.com not found'\""],
+ ["key", "severity"],
+ ["punctuation", ":"],
+ " fail\n ",
+ ["key", "data"],
+ ["punctuation", ":"],
+ ["key", "got"],
+ ["punctuation", ":"],
+ ["key", "hostname"],
+ ["punctuation", ":"],
+ ["string", "'peebles.example.com'"],
+ ["key", "address"],
+ ["punctuation", ":"],
+ ["null", "~"],
+ ["key", "expected"],
+ ["punctuation", ":"],
+ ["key", "hostname"],
+ ["punctuation", ":"],
+ ["string", "'peebles.example.com'"],
+ ["key", "address"],
+ ["punctuation", ":"],
+ ["string", "'85.193.201.85'"],
+ ["punctuation", "..."]
+ ]]
+]
+
+----------------------------------------------------
+
+Checks yaml embedding