3ccaec5010fe9d7fbba28db8c0d67cfcb58265db
[myslice.git] / third-party / codemirror-3.15 / mode / gfm / test.js
1 (function() {
2   var mode = CodeMirror.getMode({tabSize: 4}, "gfm");
3   function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
4
5   MT("emInWordAsterisk",
6      "foo[em *bar*]hello");
7
8   MT("emInWordUnderscore",
9      "foo_bar_hello");
10
11   MT("emStrongUnderscore",
12      "[strong __][em&strong _foo__][em _] bar");
13
14   MT("fencedCodeBlocks",
15      "[comment ```]",
16      "[comment foo]",
17      "",
18      "[comment ```]",
19      "bar");
20
21   MT("fencedCodeBlockModeSwitching",
22      "[comment ```javascript]",
23      "[variable foo]",
24      "",
25      "[comment ```]",
26      "bar");
27
28   MT("taskListAsterisk",
29      "[variable-2 * []] foo]", // Invalid; must have space or x between []
30      "[variable-2 * [ ]]bar]", // Invalid; must have space after ]
31      "[variable-2 * [x]]hello]", // Invalid; must have space after ]
32      "[variable-2 * ][meta [ ]]][variable-2  [world]]]", // Valid; tests reference style links
33      "    [variable-3 * ][property [x]]][variable-3  foo]"); // Valid; can be nested
34
35   MT("taskListPlus",
36      "[variable-2 + []] foo]", // Invalid; must have space or x between []
37      "[variable-2 + [ ]]bar]", // Invalid; must have space after ]
38      "[variable-2 + [x]]hello]", // Invalid; must have space after ]
39      "[variable-2 + ][meta [ ]]][variable-2  [world]]]", // Valid; tests reference style links
40      "    [variable-3 + ][property [x]]][variable-3  foo]"); // Valid; can be nested
41
42   MT("taskListDash",
43      "[variable-2 - []] foo]", // Invalid; must have space or x between []
44      "[variable-2 - [ ]]bar]", // Invalid; must have space after ]
45      "[variable-2 - [x]]hello]", // Invalid; must have space after ]
46      "[variable-2 - ][meta [ ]]][variable-2  [world]]]", // Valid; tests reference style links
47      "    [variable-3 - ][property [x]]][variable-3  foo]"); // Valid; can be nested
48
49   MT("taskListNumber",
50      "[variable-2 1. []] foo]", // Invalid; must have space or x between []
51      "[variable-2 2. [ ]]bar]", // Invalid; must have space after ]
52      "[variable-2 3. [x]]hello]", // Invalid; must have space after ]
53      "[variable-2 4. ][meta [ ]]][variable-2  [world]]]", // Valid; tests reference style links
54      "    [variable-3 1. ][property [x]]][variable-3  foo]"); // Valid; can be nested
55
56   MT("SHA",
57      "foo [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] bar");
58
59   MT("shortSHA",
60      "foo [link be6a8cc] bar");
61
62   MT("tooShortSHA",
63      "foo be6a8c bar");
64
65   MT("longSHA",
66      "foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar");
67
68   MT("badSHA",
69      "foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar");
70
71   MT("userSHA",
72      "foo [link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] hello");
73
74   MT("userProjectSHA",
75      "foo [link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] world");
76
77   MT("num",
78      "foo [link #1] bar");
79
80   MT("badNum",
81      "foo #1bar hello");
82
83   MT("userNum",
84      "foo [link bar#1] hello");
85
86   MT("userProjectNum",
87      "foo [link bar/hello#1] world");
88
89   MT("vanillaLink",
90      "foo [link http://www.example.com/] bar");
91
92   MT("vanillaLinkPunctuation",
93      "foo [link http://www.example.com/]. bar");
94
95   MT("vanillaLinkExtension",
96      "foo [link http://www.example.com/index.html] bar");
97
98   MT("notALink",
99      "[comment ```css]",
100      "[tag foo] {[property color][operator :][keyword black];}",
101      "[comment ```][link http://www.example.com/]");
102
103   MT("notALink",
104      "[comment ``foo `bar` http://www.example.com/``] hello");
105
106   MT("notALink",
107      "[comment `foo]",
108      "[link http://www.example.com/]",
109      "[comment `foo]",
110      "",
111      "[link http://www.example.com/]");
112 })();