test.min.js (1887B)
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({}, "shell"); 6 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); } 7 8 MT("var", 9 "text [def $var] text"); 10 MT("varBraces", 11 "text[def ${var}]text"); 12 MT("varVar", 13 "text [def $a$b] text"); 14 MT("varBracesVarBraces", 15 "text[def ${a}${b}]text"); 16 17 MT("singleQuotedVar", 18 "[string 'text $var text']"); 19 MT("singleQuotedVarBraces", 20 "[string 'text ${var} text']"); 21 22 MT("doubleQuotedVar", 23 '[string "text ][def $var][string text"]'); 24 MT("doubleQuotedVarBraces", 25 '[string "text][def ${var}][string text"]'); 26 MT("doubleQuotedVarPunct", 27 '[string "text ][def $@][string text"]'); 28 MT("doubleQuotedVarVar", 29 '[string "][def $a$b][string "]'); 30 MT("doubleQuotedVarBracesVarBraces", 31 '[string "][def ${a}${b}][string "]'); 32 33 MT("notAString", 34 "text\\'text"); 35 MT("escapes", 36 "outside\\'\\\"\\`\\\\[string \"inside\\`\\'\\\"\\\\`\\$notAVar\"]outside\\$\\(notASubShell\\)"); 37 38 MT("subshell", 39 "[builtin echo] [quote $(whoami)] s log, stardate [quote `date`]."); 40 MT("doubleQuotedSubshell", 41 "[builtin echo] [string \"][quote $(whoami)][string 's log, stardate `date`.\"]"); 42 43 MT("hashbang", 44 "[meta #!/bin/bash]"); 45 MT("comment", 46 "text [comment # Blurb]"); 47 48 MT("numbers", 49 "[number 0] [number 1] [number 2]"); 50 MT("keywords", 51 "[keyword while] [atom true]; [keyword do]", 52 " [builtin sleep] [number 3]", 53 "[keyword done]"); 54 MT("options", 55 "[builtin ls] [attribute -l] [attribute --human-readable]"); 56 MT("operator", 57 "[def var][operator =]value"); 58 59 MT("doubleParens", 60 "foo [quote $((bar))]") 61 62 MT("nested braces", 63 "[builtin echo] [def ${A[${B}]]}]") 64 })();