test.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://codemirror.net/LICENSE
  3. (function() {
  4. var mode = CodeMirror.getMode({indentUnit: 4},
  5. {name: "python",
  6. version: 3,
  7. singleLineStringErrors: false});
  8. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  9. // Error, because "foobarhello" is neither a known type or property, but
  10. // property was expected (after "and"), and it should be in parentheses.
  11. MT("decoratorStartOfLine",
  12. "[meta @dec]",
  13. "[keyword def] [def function]():",
  14. " [keyword pass]");
  15. MT("decoratorIndented",
  16. "[keyword class] [def Foo]:",
  17. " [meta @dec]",
  18. " [keyword def] [def function]():",
  19. " [keyword pass]");
  20. MT("matmulWithSpace:", "[variable a] [operator @] [variable b]");
  21. MT("matmulWithoutSpace:", "[variable a][operator @][variable b]");
  22. MT("matmulSpaceBefore:", "[variable a] [operator @][variable b]");
  23. var before_equal_sign = ["+", "-", "*", "/", "=", "!", ">", "<"];
  24. for (var i = 0; i < before_equal_sign.length; ++i) {
  25. var c = before_equal_sign[i]
  26. MT("before_equal_sign_" + c, "[variable a] [operator " + c + "=] [variable b]");
  27. }
  28. MT("fValidStringPrefix", "[string f'this is a]{[variable formatted]}[string string']");
  29. MT("fValidExpressioninFString", "[string f'expression ]{[number 100][operator *][number 5]}[string string']");
  30. MT("fInvalidFString", "[error f'this is wrong}]");
  31. MT("fNestedFString", "[string f'expression ]{[number 100] [operator +] [string f'inner]{[number 5]}[string ']}[string string']");
  32. MT("uValidStringPrefix", "[string u'this is an unicode string']");
  33. })();