Licitator 1.0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

288 lines
11 KiB

5 years ago
  1. <!doctype html>
  2. <meta charset="utf-8"/>
  3. <title>CodeMirror: Test Suite</title>
  4. <link rel=stylesheet href="../doc/docs.css">
  5. <link rel="stylesheet" href="../lib/codemirror.css">
  6. <link rel="stylesheet" href="mode_test.css">
  7. <script>
  8. var errored = []
  9. window.onerror = function(e) { errored.push(e) }
  10. </script>
  11. <script src="../doc/activebookmark.js"></script>
  12. <script src="../lib/codemirror.js"></script>
  13. <script src="../mode/meta.js"></script>
  14. <script src="../addon/mode/overlay.js"></script>
  15. <script src="../addon/mode/multiplex.js"></script>
  16. <script src="../addon/search/searchcursor.js"></script>
  17. <script src="../addon/dialog/dialog.js"></script>
  18. <script src="../addon/edit/matchbrackets.js"></script>
  19. <script src="../addon/hint/sql-hint.js"></script>
  20. <script src="../addon/hint/xml-hint.js"></script>
  21. <script src="../addon/hint/html-hint.js"></script>
  22. <script src="../addon/comment/comment.js"></script>
  23. <script src="../addon/mode/simple.js"></script>
  24. <script src="../mode/css/css.js"></script>
  25. <script src="../mode/clike/clike.js"></script>
  26. <!-- clike must be after css or vim and sublime tests will fail -->
  27. <script src="../mode/clojure/clojure.js"></script>
  28. <script src="../mode/cypher/cypher.js"></script>
  29. <script src="../mode/d/d.js"></script>
  30. <script src="../mode/dockerfile/dockerfile.js"></script>
  31. <script src="../mode/gfm/gfm.js"></script>
  32. <script src="../mode/haml/haml.js"></script>
  33. <script src="../mode/htmlmixed/htmlmixed.js"></script>
  34. <script src="../mode/javascript/javascript.js"></script>
  35. <script src="../mode/jsx/jsx.js"></script>
  36. <script src="../mode/markdown/markdown.js"></script>
  37. <script src="../mode/php/php.js"></script>
  38. <script src="../mode/python/python.js"></script>
  39. <script src="../mode/powershell/powershell.js"></script>
  40. <script src="../mode/ruby/ruby.js"></script>
  41. <script src="../mode/sass/sass.js"></script>
  42. <script src="../mode/shell/shell.js"></script>
  43. <script src="../mode/slim/slim.js"></script>
  44. <script src="../mode/soy/soy.js"></script>
  45. <script src="../mode/sql/sql.js"></script>
  46. <script src="../mode/stex/stex.js"></script>
  47. <script src="../mode/swift/swift.js"></script>
  48. <script src="../mode/textile/textile.js"></script>
  49. <script src="../mode/verilog/verilog.js"></script>
  50. <script src="../mode/xml/xml.js"></script>
  51. <script src="../mode/xquery/xquery.js"></script>
  52. <script src="../keymap/emacs.js"></script>
  53. <script src="../keymap/sublime.js"></script>
  54. <script src="../keymap/vim.js"></script>
  55. <script src="../mode/rust/rust.js"></script>
  56. <script src="../mode/mscgen/mscgen.js"></script>
  57. <script src="../mode/dylan/dylan.js"></script>
  58. <script src="../mode/wast/wast.js"></script>
  59. <style>
  60. .ok { color: #090; }
  61. .fail { color: #e00; }
  62. .error { color: #c90; }
  63. .done { font-weight: bold; }
  64. #progress {
  65. background: #45d;
  66. color: white;
  67. text-shadow: 0 0 1px #45d, 0 0 2px #45d, 0 0 3px #45d;
  68. font-weight: bold;
  69. white-space: pre;
  70. }
  71. #testground {
  72. visibility: hidden;
  73. }
  74. #testground.offscreen {
  75. visibility: visible;
  76. position: absolute;
  77. left: -10000px;
  78. top: -10000px;
  79. }
  80. .CodeMirror { border: 1px solid black; }
  81. </style>
  82. <div id=nav>
  83. <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
  84. <ul>
  85. <li><a href="../index.html">Home</a>
  86. <li><a href="../doc/manual.html">Manual</a>
  87. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  88. </ul>
  89. <ul>
  90. <li><a class=active href="#">Test suite</a>
  91. </ul>
  92. </div>
  93. <article>
  94. <h2>Test Suite</h2>
  95. <p>A limited set of programmatic sanity tests for CodeMirror.</p>
  96. <div style="border: 1px solid black; padding: 1px; max-width: 700px;">
  97. <div style="width: 0px;" id=progress><div style="padding: 3px;">Ran <span id="progress_ran">0</span><span id="progress_total"> of 0</span> tests</div></div>
  98. </div>
  99. <p id=status>Please enable JavaScript...</p>
  100. <div id=output></div>
  101. <div id=testground></div>
  102. <script src="driver.js"></script>
  103. <script src="test.js"></script>
  104. <script src="doc_test.js"></script>
  105. <script src="multi_test.js"></script>
  106. <script src="contenteditable_test.js"></script>
  107. <script src="scroll_test.js"></script>
  108. <script src="comment_test.js"></script>
  109. <script src="search_test.js"></script>
  110. <script src="mode_test.js"></script>
  111. <script src="../mode/clike/test.js"></script>
  112. <script src="../mode/clojure/test.js"></script>
  113. <script src="../mode/css/test.js"></script>
  114. <script src="../mode/css/gss_test.js"></script>
  115. <script src="../mode/css/scss_test.js"></script>
  116. <script src="../mode/css/less_test.js"></script>
  117. <script src="../mode/cypher/test.js"></script>
  118. <script src="../mode/d/test.js"></script>
  119. <script src="../mode/dockerfile/test.js"></script>
  120. <script src="../mode/gfm/test.js"></script>
  121. <script src="../mode/haml/test.js"></script>
  122. <script src="../mode/javascript/test.js"></script>
  123. <script src="../mode/jsx/test.js"></script>
  124. <script src="../mode/markdown/test.js"></script>
  125. <script src="../mode/php/test.js"></script>
  126. <script src="../mode/powershell/test.js"></script>
  127. <script src="../mode/ruby/test.js"></script>
  128. <script src="../mode/sass/test.js"></script>
  129. <script src="../mode/shell/test.js"></script>
  130. <script src="../mode/slim/test.js"></script>
  131. <script src="../mode/soy/test.js"></script>
  132. <script src="../mode/stex/test.js"></script>
  133. <script src="../mode/swift/test.js"></script>
  134. <script src="../mode/textile/test.js"></script>
  135. <script src="../mode/verilog/test.js"></script>
  136. <script src="../mode/xml/test.js"></script>
  137. <script src="../mode/xquery/test.js"></script>
  138. <script src="../mode/python/test.js"></script>
  139. <script src="../mode/rust/test.js"></script>
  140. <script src="../mode/wast/test.js"></script>
  141. <script src="../mode/mscgen/mscgen_test.js"></script>
  142. <script src="../mode/mscgen/xu_test.js"></script>
  143. <script src="../mode/mscgen/msgenny_test.js"></script>
  144. <script src="../mode/dylan/test.js"></script>
  145. <script src="../addon/mode/multiplex_test.js"></script>
  146. <script src="../addon/fold/foldcode.js"></script>
  147. <script src="../addon/fold/brace-fold.js"></script>
  148. <script src="emacs_test.js"></script>
  149. <script src="sql-hint-test.js"></script>
  150. <script src="sublime_test.js"></script>
  151. <script src="vim_test.js"></script>
  152. <script src="html-hint-test.js"></script>
  153. <script>
  154. window.onload = runHarness;
  155. CodeMirror.on(window, 'hashchange', runHarness);
  156. function esc(str) {
  157. return str.replace(/[<&]/, function(ch) { return ch == "<" ? "&lt;" : "&amp;"; });
  158. }
  159. var output = document.getElementById("output"),
  160. progress = document.getElementById("progress"),
  161. progressRan = document.getElementById("progress_ran").childNodes[0],
  162. progressTotal = document.getElementById("progress_total").childNodes[0];
  163. var count = 0,
  164. failed = 0,
  165. skipped = 0,
  166. bad = "",
  167. running = false, // Flag that states tests are running
  168. quit = false, // Flag to quit tests ASAP
  169. verbose = false, // Adds message for *every* test to output
  170. done = false
  171. function runHarness(){
  172. if (running) {
  173. quit = true;
  174. setStatus("Restarting tests...", '', true);
  175. setTimeout(function(){ runHarness(); }, 500);
  176. return;
  177. }
  178. filters = [];
  179. verbose = false;
  180. if (window.location.hash.substr(1)){
  181. var strings = window.location.hash.substr(1).split(",");
  182. while (strings.length) {
  183. var s = strings.shift();
  184. if (s === "verbose")
  185. verbose = true;
  186. else
  187. filters.push(parseTestFilter(decodeURIComponent(s)));
  188. }
  189. }
  190. quit = false;
  191. running = true;
  192. setStatus("Loading tests...");
  193. count = 0;
  194. failed = 0;
  195. done = false;
  196. skipped = 0;
  197. bad = "";
  198. totalTests = countTests();
  199. progressTotal.nodeValue = " of " + totalTests;
  200. progressRan.nodeValue = count;
  201. output.innerHTML = '';
  202. document.getElementById("testground").innerHTML = "<form>" +
  203. "<textarea id=\"code\" name=\"code\"></textarea>" +
  204. "<input type=submit value=ok name=submit>" +
  205. "</form>";
  206. runTests(displayTest);
  207. }
  208. function setStatus(message, className, force){
  209. if (quit && !force) return;
  210. if (!message) throw("must provide message");
  211. var status = document.getElementById("status").childNodes[0];
  212. status.nodeValue = message;
  213. status.parentNode.className = className;
  214. }
  215. function addOutput(name, className, code){
  216. var newOutput = document.createElement("dl");
  217. var newTitle = document.createElement("dt");
  218. newTitle.className = className;
  219. newTitle.appendChild(document.createTextNode(name));
  220. newOutput.appendChild(newTitle);
  221. var newMessage = document.createElement("dd");
  222. newMessage.innerHTML = code;
  223. newOutput.appendChild(newTitle);
  224. newOutput.appendChild(newMessage);
  225. output.appendChild(newOutput);
  226. }
  227. function displayTest(type, name, customMessage) {
  228. var message = "???";
  229. if (type != "done" && type != "skipped") ++count;
  230. progress.style.width = (count * (progress.parentNode.clientWidth - 2) / (totalTests || 1)) + "px";
  231. progressRan.nodeValue = count;
  232. if (type == "ok") {
  233. message = "Test '" + name + "' passed";
  234. if (!verbose) customMessage = false;
  235. } else if (type == "skipped") {
  236. message = "Test '" + name + "' skipped";
  237. ++skipped;
  238. if (!verbose) customMessage = false;
  239. } else if (type == "expected") {
  240. message = "Test '" + name + "' failed as expected";
  241. if (!verbose) customMessage = false;
  242. } else if (type == "error" || type == "fail") {
  243. ++failed;
  244. message = "Test '" + name + "' failed";
  245. } else if (type == "done") {
  246. if (failed) {
  247. type += " fail";
  248. message = failed + " failure" + (failed > 1 ? "s" : "");
  249. } else if (count < totalTests) {
  250. failed = totalTests - count;
  251. type += " fail";
  252. message = failed + " failure" + (failed > 1 ? "s" : "");
  253. } else {
  254. type += " ok";
  255. message = "All passed"
  256. if (skipped) {
  257. message += " (" + skipped + " skipped)";
  258. }
  259. }
  260. done = true
  261. progressTotal.nodeValue = '';
  262. customMessage = true; // Hack to avoid adding to output
  263. }
  264. if (verbose && !customMessage) customMessage = message;
  265. setStatus(message, type);
  266. if (customMessage && customMessage.length > 0) {
  267. addOutput(name, type, customMessage);
  268. }
  269. }
  270. </script>
  271. </article>