Mercurial
comparison .cms/lib/codemirror/mode/shell/test.js @ 0:78edf6b517a0 draft
24.10
author | Coffee CMS <info@coffee-cms.ru> |
---|---|
date | Fri, 11 Oct 2024 22:40:23 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:78edf6b517a0 |
---|---|
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others | |
2 // Distributed under an MIT license: https://codemirror.net/5/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 | |
65 MT("strings in parens", | |
66 "[def FOO][operator =]([quote $(<][string \"][def $MYDIR][string \"][quote /myfile grep ][string 'hello$'][quote )])") | |
67 | |
68 MT("string ending in dollar", | |
69 '[def a][operator =][string "xyz$"]; [def b][operator =][string "y"]') | |
70 | |
71 MT("quote ending in dollar", | |
72 "[quote $(echo a$)]") | |
73 | |
74 MT("heredoc", | |
75 "[builtin cat] [string-2 <<- end]", | |
76 "[string-2 content one]", | |
77 "[string-2 content two end]", | |
78 "[string-2 end]", | |
79 "[builtin echo]") | |
80 })(); |