Tests: Added `.html.test` files for replace `.js` language tests (#3148)
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 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692
diff --git a/package-lock.json b/package-lock.json
index c9647b2..949c916 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -6102,6 +6102,12 @@
"integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=",
"dev": true
},
+ "prettier": {
+ "version": "2.4.1",
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz",
+ "integrity": "sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==",
+ "dev": true
+ },
"pretty-hrtime": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz",
diff --git a/package.json b/package.json
index 487ccd7..1961040 100755
--- a/package.json
+++ b/package.json
@@ -61,6 +61,7 @@
"mocha": "^6.2.0",
"node-fetch": "^2.6.0",
"npm-run-all": "^4.1.5",
+ "prettier": "^2.4.1",
"pump": "^3.0.0",
"refa": "^0.9.1",
"regexp-ast-analysis": "^0.2.4",
diff --git a/test-suite.html b/test-suite.html
index 0dbd535..c4ae782 100644
--- a/test-suite.html
+++ b/test-suite.html
@@ -165,14 +165,21 @@ This is a comment explaining this test case.</code></pre>
<section id="writing-specific-tests">
<h1>Writing specific tests</h1>
- <p>Sometimes, using the token stream tests is not powerful enough. By creating a test file with the file extension <code>.js</code> instead of <code>.test</code>, you can make Prism highlight arbitrary pieces of code and check their HTML results.</p>
+ <p>Sometimes, using the token stream tests is not powerful enough. By creating a test file with the file extension <code>.html.test</code> instead of <code>.test</code>, you can make Prism highlight arbitrary pieces of code and check their HTML results.</p>
<p>The language is determined by the folder containing the test file lies, as explained in the previous section.</p>
<p>The structure of your test file will look like this, for example:</p>
- <pre><code>module.exports = {
- '&#x278a;': '<span class="token entity" title="&#x278a;">&amp;#x278a;</span>',
- '&#182;': '<span class="token entity" title="&#182;">&amp;#182;</span>',
-};</code></pre>
- <p>The keys are the codes which will be highlighted by Prism. The values are the expected results, as HTML.</p>
+ <pre><code class="language-html">&amp;
+&#x41;
+
+----------------------------------------------------
+
+<span class="token entity named-entity" title="&amp;">&amp;amp;</span>
+<span class="token entity" title="&#x41;">&amp;#x41;</span>
+
+----------------------------------------------------
+
+This is a comment explaining this test case.
+</code></pre>
</section>
<section id="test-runner-tests">
diff --git a/tests/helper/test-case.js b/tests/helper/test-case.js
index e073613..3454d77 100644
--- a/tests/helper/test-case.js
+++ b/tests/helper/test-case.js
@@ -2,6 +2,7 @@
const fs = require('fs');
const { assert } = require('chai');
+const Prettier = require('prettier');
const PrismLoader = require('./prism-loader');
const TokenStreamTransformer = require('./token-stream-transformer');
@@ -217,6 +218,81 @@ class TokenizeJSONRunner {
}
}
+/**
+ * @implements {Runner<string>}
+ */
+class HighlightHTMLRunner {
+ /**
+ * @param {Prism} Prism
+ * @param {string} code
+ * @param {string} language
+ * @returns {string}
+ */
+ run(Prism, code, language) {
+ const env = {
+ element: {},
+ language,
+ grammar: Prism.languages[language],
+ code,
+ };
+
+ Prism.hooks.run('before-highlight', env);
+ env.highlightedCode = Prism.highlight(env.code, env.grammar, env.language);
+ Prism.hooks.run('before-insert', env);
+ env.element.innerHTML = env.highlightedCode;
+ Prism.hooks.run('after-highlight', env);
+ Prism.hooks.run('complete', env);
+
+ return env.highlightedCode;
+ }
+ /**
+ * @param {string} actual
+ * @returns {string}
+ */
+ print(actual) {
+ return Prettier.format(actual, {
+ printWidth: 100,
+ tabWidth: 4,
+ useTabs: true,
+ htmlWhitespaceSensitivity: 'ignore',
+ filepath: 'fake.html',
+ });
+ }
+ /**
+ * @param {string} actual
+ * @param {string} expected
+ * @returns {boolean}
+ */
+ isEqual(actual, expected) {
+ return this.normalize(actual) === this.normalize(expected);
+ }
+ /**
+ * @param {string} actual
+ * @param {string} expected
+ * @param {(firstDifference: number) => string} message
+ * @returns {void}
+ */
+ assertEqual(actual, expected, message) {
+ // We don't calculate the index of the first difference because it's difficult.
+ assert.deepEqual(this.normalize(actual), this.normalize(expected), message(0));
+ }
+
+ /**
+ * Normalizes the given HTML by removing all leading spaces and trailing spaces. Line breaks will also be normalized
+ * to enable good diffing.
+ *
+ * @param {string} html
+ * @returns {string}
+ */
+ normalize(html) {
+ return html
+ .replace(/</g, '\n<')
+ .replace(/>/g, '>\n')
+ .replace(/[ \t]*[\r\n]\s*/g, '\n')
+ .trim();
+ }
+}
+
module.exports = {
TestCaseFile,
@@ -238,7 +314,11 @@ module.exports = {
* @param {"none" | "insert" | "update"} updateMode
*/
runTestCase(languageIdentifier, filePath, updateMode) {
- this.runTestCaseWithRunner(languageIdentifier, filePath, updateMode, new TokenizeJSONRunner());
+ if (/\.html\.test$/i.test(filePath)) {
+ this.runTestCaseWithRunner(languageIdentifier, filePath, updateMode, new HighlightHTMLRunner());
+ } else {
+ this.runTestCaseWithRunner(languageIdentifier, filePath, updateMode, new TokenizeJSONRunner());
+ }
},
/**
@@ -347,38 +427,6 @@ module.exports = {
mainLanguage: mainLanguage
};
},
-
- /**
- * Runs the given pieces of codes and asserts their result.
- *
- * Code is provided as the key and expected result as the value.
- *
- * @param {string} languageIdentifier
- * @param {object} codes
- */
- runTestsWithHooks(languageIdentifier, codes) {
- const usedLanguages = this.parseLanguageNames(languageIdentifier);
- const Prism = PrismLoader.createInstance(usedLanguages.languages);
- // the first language is the main language to highlight
-
- for (const code in codes) {
- if (codes.hasOwnProperty(code)) {
- const env = {
- element: {},
- language: usedLanguages.mainLanguage,
- grammar: Prism.languages[usedLanguages.mainLanguage],
- code: code
- };
- Prism.hooks.run('before-highlight', env);
- env.highlightedCode = Prism.highlight(env.code, env.grammar, env.language);
- Prism.hooks.run('before-insert', env);
- env.element.innerHTML = env.highlightedCode;
- Prism.hooks.run('after-highlight', env);
- Prism.hooks.run('complete', env);
- assert.equal(env.highlightedCode, codes[code]);
- }
- }
- }
};
/**
diff --git a/tests/helper/test-discovery.js b/tests/helper/test-discovery.js
index c52fb25..4d97873 100644
--- a/tests/helper/test-discovery.js
+++ b/tests/helper/test-discovery.js
@@ -3,8 +3,6 @@
const fs = require('fs');
const path = require('path');
-const SUPPORTED_TEST_FILE_EXT = new Set(['.js', '.test']);
-
module.exports = {
/**
@@ -95,7 +93,7 @@ module.exports = {
getAllFiles(src) {
return fs.readdirSync(src)
.filter(fileName => {
- return SUPPORTED_TEST_FILE_EXT.has(path.extname(fileName))
+ return path.extname(fileName) === '.test'
&& fs.statSync(path.join(src, fileName)).isFile();
})
.map(fileName => {
diff --git a/tests/languages/asciidoc/entity_feature.html.test b/tests/languages/asciidoc/entity_feature.html.test
new file mode 100644
index 0000000..6d21274
--- /dev/null
+++ b/tests/languages/asciidoc/entity_feature.html.test
@@ -0,0 +1,7 @@
+➊
+¶
+
+----------------------------------------------------
+
+<span class="token entity" title="➊">&#x278a;</span>
+<span class="token entity" title="¶">&#182;</span>
diff --git a/tests/languages/asciidoc/entity_feature.js b/tests/languages/asciidoc/entity_feature.js
deleted file mode 100644
index 22c9b3b..0000000
--- a/tests/languages/asciidoc/entity_feature.js
+++ /dev/null
@@ -1,4 +0,0 @@
-module.exports = {
- '➊': '<span class="token entity" title="➊">&#x278a;</span>',
- '¶': '<span class="token entity" title="¶">&#182;</span>'
-};
diff --git a/tests/languages/groovy/issue1049.html.test b/tests/languages/groovy/issue1049.html.test
new file mode 100644
index 0000000..0f0c618
--- /dev/null
+++ b/tests/languages/groovy/issue1049.html.test
@@ -0,0 +1,15 @@
+"&"
+"&&"
+"<"
+"<<"
+"&lt;"
+">"
+
+----------------------------------------------------
+
+<span class="token string gstring">"&amp;"</span>
+<span class="token string gstring">"&amp;&amp;"</span>
+<span class="token string gstring">"&lt;"</span>
+<span class="token string gstring">"&lt;&lt;"</span>
+<span class="token string gstring">"&amp;lt;"</span>
+<span class="token string gstring">"&gt;"</span>
diff --git a/tests/languages/groovy/issue1049.js b/tests/languages/groovy/issue1049.js
deleted file mode 100644
index 2ce8153..0000000
--- a/tests/languages/groovy/issue1049.js
+++ /dev/null
@@ -1,8 +0,0 @@
-module.exports = {
- '"&"': '<span class="token string gstring">"&amp;"</span>',
- '"&&"': '<span class="token string gstring">"&amp;&amp;"</span>',
- '"<"': '<span class="token string gstring">"&lt;"</span>',
- '"<<"': '<span class="token string gstring">"&lt;&lt;"</span>',
- '"&lt;"': '<span class="token string gstring">"&amp;lt;"</span>',
- '">"': '<span class="token string gstring">"&gt;"</span>',
-};
diff --git a/tests/languages/groovy/string-interpolation_feature.html.test b/tests/languages/groovy/string-interpolation_feature.html.test
new file mode 100644
index 0000000..1554187
--- /dev/null
+++ b/tests/languages/groovy/string-interpolation_feature.html.test
@@ -0,0 +1,133 @@
+// Double quoted: interpolation
+"$foo"
+"${42}"
+
+// Triple double quoted: interpolation
+"""$foo"""
+"""${42}"""
+
+// Slashy string: interpolation
+/$foo/
+/${42}/
+
+// Dollar slashy string: interpolation
+$/$foo/$
+$/${42}/$
+
+// Double quoted: no interpolation (escaped)
+"\$foo \${42}"
+
+// Triple double quoted: no interpolation (escaped)
+"""\$foo \${42}"""
+
+// Slashy string: no interpolation (escaped)
+/\$foo \${42}/
+
+// Dollar slashy string: no interpolation (escaped)
+$/$$foo $${42}/$
+
+// Single quoted string: no interpolation
+'$foo ${42}'
+
+// Triple single quoted string: no interpolation
+'''$foo ${42}'''
+
+----------------------------------------------------
+
+<span class="token comment">// Double quoted: interpolation</span>
+<span class="token string gstring">
+ "
+ <span class="token expression">
+ <span class="token punctuation">$</span>
+ foo
+ </span>
+ "
+</span>
+<span class="token string gstring">
+ "
+ <span class="token expression">
+ <span class="token punctuation">$</span>
+ <span class="token punctuation">{</span>
+ <span class="token number">42</span>
+ <span class="token punctuation">}</span>
+ </span>
+ "
+</span>
+
+<span class="token comment">// Triple double quoted: interpolation</span>
+<span class="token string gstring">
+ """
+ <span class="token expression">
+ <span class="token punctuation">$</span>
+ foo
+ </span>
+ """
+</span>
+<span class="token string gstring">
+ """
+ <span class="token expression">
+ <span class="token punctuation">$</span>
+ <span class="token punctuation">{</span>
+ <span class="token number">42</span>
+ <span class="token punctuation">}</span>
+ </span>
+ """
+</span>
+
+<span class="token comment">// Slashy string: interpolation</span>
+<span class="token string regex">
+ /
+ <span class="token expression">
+ <span class="token punctuation">$</span>
+ foo
+ </span>
+ /
+</span>
+<span class="token string regex">
+ /
+ <span class="token expression">
+ <span class="token punctuation">$</span>
+ <span class="token punctuation">{</span>
+ <span class="token number">42</span>
+ <span class="token punctuation">}</span>
+ </span>
+ /
+</span>
+
+<span class="token comment">// Dollar slashy string: interpolation</span>
+<span class="token string gstring">
+ $/
+ <span class="token expression">
+ <span class="token punctuation">$</span>
+ foo
+ </span>
+ /$
+</span>
+<span class="token string gstring">
+ $/
+ <span class="token expression">
+ <span class="token punctuation">$</span>
+ <span class="token punctuation">{</span>
+ <span class="token number">42</span>
+ <span class="token punctuation">}</span>
+ </span>
+ /$
+</span>
+
+<span class="token comment">// Double quoted: no interpolation (escaped)</span>
+<span class="token string gstring">"\$foo \${42}"</span>
+
+<span class="token comment">// Triple double quoted: no interpolation (escaped)</span>
+<span class="token string gstring">"""\$foo \${42}"""</span>
+
+<span class="token comment">// Slashy string: no interpolation (escaped)</span>
+<span class="token string regex">/\$foo \${42}/</span>
+
+<span class="token comment">// Dollar slashy string: no interpolation (escaped)</span>
+<span class="token string gstring">$/$$foo $${42}/$</span>
+
+<span class="token comment">// Single quoted string: no interpolation</span>
+<span class="token string">'$foo ${42}'</span>
+
+<span class="token comment">// Triple single quoted string: no interpolation</span>
+<span class="token string">'''$foo ${42}'''</span>
diff --git a/tests/languages/groovy/string-interpolation_feature.js b/tests/languages/groovy/string-interpolation_feature.js
deleted file mode 100644
index 5cb2acf..0000000
--- a/tests/languages/groovy/string-interpolation_feature.js
+++ /dev/null
@@ -1,28 +0,0 @@
-module.exports = {
- // Double quoted: interpolation
- '"$foo"': '<span class="token string gstring">"<span class="token expression"><span class="token punctuation">$</span>foo</span>"</span>',
- '"${42}"': '<span class="token string gstring">"<span class="token expression"><span class="token punctuation">$</span><span class="token punctuation">{</span><span class="token number">42</span><span class="token punctuation">}</span></span>"</span>',
- // Triple double quoted: interpolation
- '"""$foo"""': '<span class="token string gstring">"""<span class="token expression"><span class="token punctuation">$</span>foo</span>"""</span>',
- '"""${42}"""': '<span class="token string gstring">"""<span class="token expression"><span class="token punctuation">$</span><span class="token punctuation">{</span><span class="token number">42</span><span class="token punctuation">}</span></span>"""</span>',
- // Slashy string: interpolation
- '/$foo/': '<span class="token string regex">/<span class="token expression"><span class="token punctuation">$</span>foo</span>/</span>',
- '/${42}/': '<span class="token string regex">/<span class="token expression"><span class="token punctuation">$</span><span class="token punctuation">{</span><span class="token number">42</span><span class="token punctuation">}</span></span>/</span>',
- // Dollar slashy string: interpolation
- '$/$foo/$': '<span class="token string gstring">$/<span class="token expression"><span class="token punctuation">$</span>foo</span>/$</span>',
- '$/${42}/$': '<span class="token string gstring">$/<span class="token expression"><span class="token punctuation">$</span><span class="token punctuation">{</span><span class="token number">42</span><span class="token punctuation">}</span></span>/$</span>',
-
- // Double quoted: no interpolation (escaped)
- '"\\$foo \\${42}"': '<span class="token string gstring">"\\$foo \\${42}"</span>',
- // Triple double quoted: no interpolation (escaped)
- '"""\\$foo \\${42}"""': '<span class="token string gstring">"""\\$foo \\${42}"""</span>',
- // Slashy string: no interpolation (escaped)
- '/\\$foo \\${42}/': '<span class="token string regex">/\\$foo \\${42}/</span>',
- // Dollar slashy string: no interpolation (escaped)
- '$/$$foo $${42}/$': '<span class="token string gstring">$/$$foo $${42}/$</span>',
-
- // Single quoted string: no interpolation
- '\'$foo ${42}\'': '<span class="token string">\'$foo ${42}\'</span>',
- // Triple single quoted string: no interpolation
- '\'\'\'$foo ${42}\'\'\'': '<span class="token string">\'\'\'$foo ${42}\'\'\'</span>'
-};
diff --git a/tests/languages/markdown/code-block_feature.html.test b/tests/languages/markdown/code-block_feature.html.test
new file mode 100644
index 0000000..7a5e856
--- /dev/null
+++ b/tests/languages/markdown/code-block_feature.html.test
@@ -0,0 +1,49 @@
+```html
+<a href="#foo">Click me!</a> &
+```
+
+```unknownLanguage
+<a href="#foo">Click me!</a> &
+```
+
+----------------------------------------------------
+
+<span class="token code">
+ <span class="token punctuation">```</span>
+ <span class="token code-language">html</span>
+ <span class="token code-block language-html">
+ <span class="token tag">
+ <span class="token tag">
+ <span class="token punctuation"><</span>
+ a
+ </span>
+ <span class="token attr-name">href</span>
+ <span class="token attr-value">
+ <span class="token punctuation attr-equals">=</span>
+ <span class="token punctuation">"</span>
+ #foo
+ <span class="token punctuation">"</span>
+ </span>
+ <span class="token punctuation">></span>
+ </span>
+ Click me!
+ <span class="token tag">
+ <span class="token tag">
+ <span class="token punctuation"></</span>
+ a
+ </span>
+ <span class="token punctuation">></span>
+ </span>
+ <span class="token entity named-entity" title="&">&amp;</span>
+ </span>
+ <span class="token punctuation">```</span>
+</span>
+
+<span class="token code">
+ <span class="token punctuation">```</span>
+ <span class="token code-language">unknownLanguage</span>
+ <span class="token code-block language-unknownlanguage">
+ <a href="#foo">Click me!</a> &amp;
+ </span>
+ <span class="token punctuation">```</span>
+</span>
diff --git a/tests/languages/markdown/code-block_feature.js b/tests/languages/markdown/code-block_feature.js
deleted file mode 100644
index e879cfa..0000000
--- a/tests/languages/markdown/code-block_feature.js
+++ /dev/null
@@ -1,5 +0,0 @@
-module.exports = {
- '```html\n<a href="#foo">Click me!</a> &\n```\n': '<span class="token code"><span class="token punctuation">```</span><span class="token code-language">html</span>\n<span class="token code-block language-html"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>a</span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>#foo<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Click me!<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>a</span><span class="token punctuation">></span></span> <span class="token entity named-entity" title="&">&amp;</span></span>\n<span class="token punctuation">```</span></span>\n',
-
- '```unknownLanguage\n<a href="#foo">Click me!</a> &\n```\n': '<span class="token code"><span class="token punctuation">```</span><span class="token code-language">unknownLanguage</span>\n<span class="token code-block language-unknownlanguage"><a href="#foo">Click me!</a> &amp;</span>\n<span class="token punctuation">```</span></span>\n',
-};
diff --git a/tests/languages/markdown/code_block_language_detection_feature.html.test b/tests/languages/markdown/code_block_language_detection_feature.html.test
new file mode 100644
index 0000000..d47fcba
--- /dev/null
+++ b/tests/languages/markdown/code_block_language_detection_feature.html.test
@@ -0,0 +1,45 @@
+```js
+let a = 0;
+```
+
+``` c++
+int a = 0;
+```
+
+``` c#
+var a = 0;
+```
+
+```{r pressure, echo=FALSE}
+plot(pressure)
+```
+
+----------------------------------------------------
+
+<span class="token code">
+ <span class="token punctuation">```</span>
+ <span class="token code-language">js</span>
+ <span class="token code-block language-js">let a = 0;</span>
+ <span class="token punctuation">```</span>
+</span>
+
+<span class="token code">
+ <span class="token punctuation">```</span>
+ <span class="token code-language">c++</span>
+ <span class="token code-block language-cpp">int a = 0;</span>
+ <span class="token punctuation">```</span>
+</span>
+
+<span class="token code">
+ <span class="token punctuation">```</span>
+ <span class="token code-language">c#</span>
+ <span class="token code-block language-csharp">var a = 0;</span>
+ <span class="token punctuation">```</span>
+</span>
+
+<span class="token code">
+ <span class="token punctuation">```</span>
+ <span class="token code-language">{r pressure, echo=FALSE}</span>
+ <span class="token code-block language-r">plot(pressure)</span>
+ <span class="token punctuation">```</span>
+</span>
diff --git a/tests/languages/markdown/code_block_language_detection_feature.js b/tests/languages/markdown/code_block_language_detection_feature.js
deleted file mode 100644
index c980b6c..0000000
--- a/tests/languages/markdown/code_block_language_detection_feature.js
+++ /dev/null
@@ -1,11 +0,0 @@
-module.exports = {
-
- '```js\nlet a = 0;\n```': '<span class="token code"><span class="token punctuation">```</span><span class="token code-language">js</span>\n<span class="token code-block language-js">let a = 0;</span>\n<span class="token punctuation">```</span></span>',
-
- '``` c++\nint a = 0;\n```': '<span class="token code"><span class="token punctuation">```</span><span class="token code-language"> c++</span>\n<span class="token code-block language-cpp">int a = 0;</span>\n<span class="token punctuation">```</span></span>',
-
- '``` c#\nvar a = 0;\n```': '<span class="token code"><span class="token punctuation">```</span><span class="token code-language"> c#</span>\n<span class="token code-block language-csharp">var a = 0;</span>\n<span class="token punctuation">```</span></span>',
-
- '```{r pressure, echo=FALSE}\nplot(pressure)\n```': '<span class="token code"><span class="token punctuation">```</span><span class="token code-language">{r pressure, echo=FALSE}</span>\n<span class="token code-block language-r">plot(pressure)</span>\n<span class="token punctuation">```</span></span>'
-
-};
diff --git a/tests/languages/markup/entity_feature.html.test b/tests/languages/markup/entity_feature.html.test
new file mode 100644
index 0000000..5bcf351
--- /dev/null
+++ b/tests/languages/markup/entity_feature.html.test
@@ -0,0 +1,17 @@
+&
+ϑ
+A
+A
+⛵
+
+----------------------------------------------------
+
+<span class="token entity named-entity" title="&">&amp;</span>
+<span class="token entity named-entity" title="ϑ">&thetasym;</span>
+<span class="token entity" title="A">&#65;</span>
+<span class="token entity" title="A">&#x41;</span>
+<span class="token entity" title="⛵">&#x26f5;</span>
+
+----------------------------------------------------
+
+Checks for HTML/XML character entity references.
diff --git a/tests/languages/markup/entity_feature.js b/tests/languages/markup/entity_feature.js
deleted file mode 100644
index ec74c9e..0000000
--- a/tests/languages/markup/entity_feature.js
+++ /dev/null
@@ -1,6 +0,0 @@
-module.exports = {
- '&': '<span class="token entity named-entity" title="&">&amp;</span>',
- 'ϑ': '<span class="token entity named-entity" title="ϑ">&thetasym;</span>',
- 'A': '<span class="token entity" title="A">&#65;</span>',
- 'A': '<span class="token entity" title="A">&#x41;</span>'
-};
diff --git a/tests/languages/markup/entity_feature.test b/tests/languages/markup/entity_feature.test
deleted file mode 100644
index 44f0f83..0000000
--- a/tests/languages/markup/entity_feature.test
+++ /dev/null
@@ -1,14 +0,0 @@
-& ϑ ⛵  
-
-----------------------------------------------------
-
-[
- ["entity", "&"],
- ["entity", "ϑ"],
- ["entity", "⛵"],
- ["entity", " "]
-]
-
-----------------------------------------------------
-
-Checks for HTML/XML character entity references.
\ No newline at end of file
diff --git a/tests/pattern-tests.js b/tests/pattern-tests.js
index 7cfb2d0..2dc9ee4 100644
--- a/tests/pattern-tests.js
+++ b/tests/pattern-tests.js
@@ -10,7 +10,6 @@ const { languages } = require('../components.json');
const { visitRegExpAST } = require('regexpp');
const { transform, combineTransformers, getIntersectionWordSets, JS, Words, NFA, Transformers } = require('refa');
const scslre = require('scslre');
-const path = require('path');
const { argv } = require('yargs');
const RAA = require('regexp-ast-analysis');
@@ -30,11 +29,7 @@ for (const languageIdentifier in testSuite) {
}
for (const file of testSuite[languageIdentifier]) {
- if (path.extname(file) === '.test') {
- snippets.push(TestCase.TestCaseFile.readFromFile(file).code);
- } else {
- snippets.push(...Object.keys(require(file)));
- }
+ snippets.push(TestCase.TestCaseFile.readFromFile(file).code);
}
}
diff --git a/tests/run.js b/tests/run.js
index d6a3882..f030fbc 100644
--- a/tests/run.js
+++ b/tests/run.js
@@ -28,11 +28,7 @@ for (const language in testSuite) {
const fileName = path.basename(filePath, path.extname(filePath));
it("– should pass test case '" + fileName + "'", function () {
- if (path.extname(filePath) === '.test') {
- TestCase.runTestCase(language, filePath, update ? 'update' : 'insert');
- } else {
- TestCase.runTestsWithHooks(language, require(filePath));
- }
+ TestCase.runTestCase(language, filePath, update ? 'update' : 'insert');
});
}
});