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