From 791dad0d64cd61bf8481bb92855e337ac24cbe0e Mon Sep 17 00:00:00 2001 From: Golmote Date: Thu, 27 Aug 2015 20:57:37 +0200 Subject: [PATCH] Tests: Increase the minimum number of dashes for the separation + fix test-suite page to match the actual behaviour. --- test-suite.html | 8 ++++---- tests/helper/test-case.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test-suite.html b/test-suite.html index accd149d92..51d397d627 100644 --- a/test-suite.html +++ b/test-suite.html @@ -47,14 +47,14 @@

Example 2: testing language injection

If you want to test language injection, you typically need to load two or more languages where one language is the “main” language that is being tested, with all other languages being injected into it.

You need to define multiple languages by separating them using a + sign: markup+php.

The languages are loaded in order, so first markup (+ dependencies) is loaded, then php (+ dependencies). The test loader ensures that no language is loaded more than once (for example if two languages have the same dependencies).

-

By default the first language is the main language: markup+php will have markup as main language. This is equal to putting your code in the following code block:

+

By default the last language is the main language: php+markup will have markup as main language. This is equal to putting your code in the following code block:

...
 <pre><code class="language-markup">
 	<!-- your code here -->
 </code><pre>
 ...
-

If you need to load the languages in a given order, but you don't want to use the first language as main language, you can mark the main language with an exclamation mark: markup+php!. This will use php as main language. (You can only define one main language. The test runner will fail all tests in directories with more than one main language.)

+

If you need to load the languages in a given order, but you don't want to use the first language as main language, you can mark the main language with an exclamation mark: php!+markup. This will use php as main language. (You can only define one main language. The test runner will fail all tests in directories with more than one main language.)

Note: by loading multiple languages you can do integration tests (ensure that loading two or more languages together won't break anything).

@@ -66,7 +66,7 @@

Creating your test case file

You can use all conventions as a prefix, so string_interpolation_feature_inline.test is possible. But please take a minute or two to think of a proper name of your test case file. You are writing code not only for the computers, but also for your fellow developers.

@@ -79,7 +79,7 @@

Writing your test

---- ... the simplified token stream you expect ... -

Your file is built up of two or three sections, separated by three or more dashes -, starting at the begin of the line:

+

Your file is built up of two or three sections, separated by four or more dashes -, starting at the begin of the line:

  1. Your language snippet. The code you want to compile using Prism. (required)
  2. The simplified token stream you expect. Needs to be valid JSON. (required)
  3. diff --git a/tests/helper/test-case.js b/tests/helper/test-case.js index 1fbe8c4b7d..cba3117698 100644 --- a/tests/helper/test-case.js +++ b/tests/helper/test-case.js @@ -120,7 +120,7 @@ module.exports = { */ parseTestCaseFile: function (filePath) { var testCaseSource = fs.readFileSync(filePath, "utf8"); - var testCaseParts = testCaseSource.split(/^----*\w*$/m); + var testCaseParts = testCaseSource.split(/^-{4,}\w*$/m); try { var testCase = {