all repos — NoPaste @ 4d5201f1a9fd36bf5ab4e04de97fc70c12081b9a

Resurrected - The PussTheCat.org fork of NoPaste

scripts/CodeMirror/mode/python/test.js (view raw)

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