You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.9 KiB

2 months ago
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://codemirror.net/5/LICENSE
  3. (function() {
  4. var mode = CodeMirror.getMode({indentUnit: 2}, "powershell");
  5. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  6. function forEach(arr, f) { for (var i = 0; i < arr.length; i++) f(arr[i], i) }
  7. MT('comment', '[number 1][comment # A]');
  8. MT('comment_multiline', '[number 1][comment <#]',
  9. '[comment ABC]',
  10. '[comment #>][number 2]');
  11. forEach([
  12. '0', '1234',
  13. '12kb', '12mb', '12Gb', '12Tb', '12PB', '12L', '12D', '12lkb', '12dtb',
  14. '1.234', '1.234e56', '1.', '1.e2', '.2', '.2e34',
  15. '1.2MB', '1.kb', '.1dTB', '1.e1gb', '.2', '.2e34',
  16. '0x1', '0xabcdef', '0x3tb', '0xelmb'
  17. ], function(number) {
  18. MT("number_" + number, "[number " + number + "]");
  19. });
  20. MT('string_literal_escaping', "[string 'a''']");
  21. MT('string_literal_variable', "[string 'a $x']");
  22. MT('string_escaping_1', '[string "a `""]');
  23. MT('string_escaping_2', '[string "a """]');
  24. MT('string_variable_escaping', '[string "a `$x"]');
  25. MT('string_variable', '[string "a ][variable-2 $x][string b"]');
  26. MT('string_variable_spaces', '[string "a ][variable-2 ${x y}][string b"]');
  27. MT('string_expression', '[string "a ][punctuation $(][variable-2 $x][operator +][number 3][punctuation )][string b"]');
  28. MT('string_expression_nested', '[string "A][punctuation $(][string "a][punctuation $(][string "w"][punctuation )][string b"][punctuation )][string B"]');
  29. MT('string_heredoc', '[string @"]',
  30. '[string abc]',
  31. '[string "@]');
  32. MT('string_heredoc_quotes', '[string @"]',
  33. '[string abc "\']',
  34. '[string "@]');
  35. MT('string_heredoc_variable', '[string @"]',
  36. '[string a ][variable-2 $x][string b]',
  37. '[string "@]');
  38. MT('string_heredoc_nested_string', '[string @"]',
  39. '[string a][punctuation $(][string "w"][punctuation )][string b]',
  40. '[string "@]');
  41. MT('string_heredoc_literal_quotes', "[string @']",
  42. '[string abc "\']',
  43. "[string '@]");
  44. MT('array', "[punctuation @(][string 'a'][punctuation ,][string 'b'][punctuation )]");
  45. MT('hash', "[punctuation @{][string 'key'][operator :][string 'value'][punctuation }]");
  46. MT('variable', "[variable-2 $test]");
  47. MT('variable_global', "[variable-2 $global:test]");
  48. MT('variable_spaces', "[variable-2 ${test test}]");
  49. MT('operator_splat', "[variable-2 @x]");
  50. MT('variable_builtin', "[builtin $ErrorActionPreference]");
  51. MT('variable_builtin_symbols', "[builtin $$]");
  52. MT('operator', "[operator +]");
  53. MT('operator_unary', "[operator +][number 3]");
  54. MT('operator_long', "[operator -match]");
  55. forEach([
  56. '(', ')', '[[', ']]', '{', '}', ',', '`', ';', '.', '\\'
  57. ], function(punctuation) {
  58. MT("punctuation_" + punctuation.replace(/^[\[\]]/,''), "[punctuation " + punctuation + "]");
  59. });
  60. MT('keyword', "[keyword if]");
  61. MT('call_builtin', "[builtin Get-ChildItem]");
  62. })();