github.com/jancarloviray/community@v0.41.1-0.20170124221257-33a66c87cf2f/app/public/codemirror/mode/clike/test.js (about)

     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       "[variable-3 void] [def foo]([variable-3 void*] [variable a], [variable-3 int] [variable b]) {",
    10       "  [variable-3 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       "[variable-3 void] [def foo]() {}",
    25       "[keyword struct] [def bar]{}",
    26       "[variable-3 int] [variable-3 *][def baz]() {}");
    27  
    28    MT("double_block",
    29       "[keyword for] (;;)",
    30       "  [keyword for] (;;)",
    31       "    [variable x][operator ++];",
    32       "[keyword return];");
    33  
    34    MT("preprocessor",
    35       "[meta #define FOO 3]",
    36       "[variable-3 int] [variable foo];",
    37       "[meta #define BAR\\]",
    38       "[meta 4]",
    39       "[variable-3 unsigned] [variable-3 int] [variable bar] [operator =] [number 8];",
    40       "[meta #include <baz> ][comment // comment]")
    41  
    42  
    43    var mode_cpp = CodeMirror.getMode({indentUnit: 2}, "text/x-c++src");
    44    function MTCPP(name) { test.mode(name, mode_cpp, Array.prototype.slice.call(arguments, 1)); }
    45  
    46    MTCPP("cpp14_literal",
    47      "[number 10'000];",
    48      "[number 0b10'000];",
    49      "[number 0x10'000];",
    50      "[string '100000'];");
    51  })();