Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

test.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: http://codemirror.net/LICENSE
  3. (function() {
  4. var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-c");
  5. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  6. MT("indent",
  7. "[variable-3 void] [def foo]([variable-3 void*] [variable a], [variable-3 int] [variable b]) {",
  8. " [variable-3 int] [variable c] [operator =] [variable b] [operator +]",
  9. " [number 1];",
  10. " [keyword return] [operator *][variable a];",
  11. "}");
  12. MT("indent_switch",
  13. "[keyword switch] ([variable x]) {",
  14. " [keyword case] [number 10]:",
  15. " [keyword return] [number 20];",
  16. " [keyword default]:",
  17. " [variable printf]([string \"foo %c\"], [variable x]);",
  18. "}");
  19. MT("def",
  20. "[variable-3 void] [def foo]() {}",
  21. "[keyword struct] [def bar]{}",
  22. "[variable-3 int] [variable-3 *][def baz]() {}");
  23. MT("def_new_line",
  24. "::[variable std]::[variable SomeTerribleType][operator <][variable T][operator >]",
  25. "[def SomeLongMethodNameThatDoesntFitIntoOneLine]([keyword const] [variable MyType][operator &] [variable param]) {}")
  26. MT("double_block",
  27. "[keyword for] (;;)",
  28. " [keyword for] (;;)",
  29. " [variable x][operator ++];",
  30. "[keyword return];");
  31. MT("preprocessor",
  32. "[meta #define FOO 3]",
  33. "[variable-3 int] [variable foo];",
  34. "[meta #define BAR\\]",
  35. "[meta 4]",
  36. "[variable-3 unsigned] [variable-3 int] [variable bar] [operator =] [number 8];",
  37. "[meta #include <baz> ][comment // comment]")
  38. var mode_cpp = CodeMirror.getMode({indentUnit: 2}, "text/x-c++src");
  39. function MTCPP(name) { test.mode(name, mode_cpp, Array.prototype.slice.call(arguments, 1)); }
  40. MTCPP("cpp14_literal",
  41. "[number 10'000];",
  42. "[number 0b10'000];",
  43. "[number 0x10'000];",
  44. "[string '100000'];");
  45. })();