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.

72 lines
2.8 KiB

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