summaryrefslogtreecommitdiff
path: root/tests/utils_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2020-05-12 08:52:23 +0200
committerGitHub <noreply@github.com>2020-05-12 08:52:23 +0200
commit0668164b4ac93a5be79f5b87fae83c657124d9ab (patch)
tree71c08a5331f99515fbc859484b61d452a045dbb3 /tests/utils_tests
parente6ec76d2455d0fd57ad766acd3714538b24a8989 (diff)
Fixed E128, E741 flake8 warnings.
Diffstat (limited to 'tests/utils_tests')
-rw-r--r--tests/utils_tests/test_jslex.py118
1 files changed, 67 insertions, 51 deletions
diff --git a/tests/utils_tests/test_jslex.py b/tests/utils_tests/test_jslex.py
index bf737b8fd2..0afb329188 100644
--- a/tests/utils_tests/test_jslex.py
+++ b/tests/utils_tests/test_jslex.py
@@ -42,17 +42,29 @@ class JsTokensTest(SimpleTestCase):
(r"a=/\//,1", ["id a", "punct =", r"regex /\//", "punct ,", "dnum 1"]),
# next two are from https://www-archive.mozilla.org/js/language/js20-2002-04/rationale/syntax.html#regular-expressions # NOQA
- ("""for (var x = a in foo && "</x>" || mot ? z:/x:3;x<5;y</g/i) {xyz(x++);}""",
- ["keyword for", "punct (", "keyword var", "id x", "punct =", "id a", "keyword in",
- "id foo", "punct &&", 'string "</x>"', "punct ||", "id mot", "punct ?", "id z",
- "punct :", "regex /x:3;x<5;y</g", "punct /", "id i", "punct )", "punct {",
- "id xyz", "punct (", "id x", "punct ++", "punct )", "punct ;", "punct }"]),
- ("""for (var x = a in foo && "</x>" || mot ? z/x:3;x<5;y</g/i) {xyz(x++);}""",
- ["keyword for", "punct (", "keyword var", "id x", "punct =", "id a", "keyword in",
- "id foo", "punct &&", 'string "</x>"', "punct ||", "id mot", "punct ?", "id z",
- "punct /", "id x", "punct :", "dnum 3", "punct ;", "id x", "punct <", "dnum 5",
- "punct ;", "id y", "punct <", "regex /g/i", "punct )", "punct {",
- "id xyz", "punct (", "id x", "punct ++", "punct )", "punct ;", "punct }"]),
+ (
+ """for (var x = a in foo && "</x>" || mot ? z:/x:3;x<5;y</g/i) {xyz(x++);}""",
+ [
+ "keyword for", "punct (", "keyword var", "id x", "punct =",
+ "id a", "keyword in", "id foo", "punct &&", 'string "</x>"',
+ "punct ||", "id mot", "punct ?", "id z", "punct :",
+ "regex /x:3;x<5;y</g", "punct /", "id i", "punct )", "punct {",
+ "id xyz", "punct (", "id x", "punct ++", "punct )", "punct ;",
+ "punct }"
+ ],
+ ),
+ (
+ """for (var x = a in foo && "</x>" || mot ? z/x:3;x<5;y</g/i) {xyz(x++);}""",
+ [
+ "keyword for", "punct (", "keyword var", "id x", "punct =",
+ "id a", "keyword in", "id foo", "punct &&", 'string "</x>"',
+ "punct ||", "id mot", "punct ?", "id z", "punct /", "id x",
+ "punct :", "dnum 3", "punct ;", "id x", "punct <", "dnum 5",
+ "punct ;", "id y", "punct <", "regex /g/i", "punct )",
+ "punct {", "id xyz", "punct (", "id x", "punct ++", "punct )",
+ "punct ;", "punct }",
+ ],
+ ),
# Various "illegal" regexes that are valid according to the std.
(r"""/????/, /++++/, /[----]/ """, ["regex /????/", "punct ,", "regex /++++/", "punct ,", "regex /[----]/"]),
@@ -65,46 +77,50 @@ class JsTokensTest(SimpleTestCase):
(r"""/a[\]]b/""", [r"""regex /a[\]]b/"""]),
(r"""/[\]/]/gi""", [r"""regex /[\]/]/gi"""]),
(r"""/\[[^\]]+\]/gi""", [r"""regex /\[[^\]]+\]/gi"""]),
- (r"""
- rexl.re = {
- NAME: /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/,
- UNQUOTED_LITERAL: /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/,
- QUOTED_LITERAL: /^'(?:[^']|'')*'/,
- NUMERIC_LITERAL: /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/,
- SYMBOL: /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/
- };
- """, # NOQA
- ["id rexl", "punct .", "id re", "punct =", "punct {",
- "id NAME", "punct :", r"""regex /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/""", "punct ,",
- "id UNQUOTED_LITERAL", "punct :", r"""regex /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/""",
- "punct ,",
- "id QUOTED_LITERAL", "punct :", r"""regex /^'(?:[^']|'')*'/""", "punct ,",
- "id NUMERIC_LITERAL", "punct :", r"""regex /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/""", "punct ,",
- "id SYMBOL", "punct :", r"""regex /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/""", # NOQA
- "punct }", "punct ;"
- ]),
-
- (r"""
- rexl.re = {
- NAME: /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/,
- UNQUOTED_LITERAL: /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/,
- QUOTED_LITERAL: /^'(?:[^']|'')*'/,
- NUMERIC_LITERAL: /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/,
- SYMBOL: /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/
- };
- str = '"';
- """, # NOQA
- ["id rexl", "punct .", "id re", "punct =", "punct {",
- "id NAME", "punct :", r"""regex /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/""", "punct ,",
- "id UNQUOTED_LITERAL", "punct :", r"""regex /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/""",
- "punct ,",
- "id QUOTED_LITERAL", "punct :", r"""regex /^'(?:[^']|'')*'/""", "punct ,",
- "id NUMERIC_LITERAL", "punct :", r"""regex /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/""", "punct ,",
- "id SYMBOL", "punct :", r"""regex /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/""", # NOQA
- "punct }", "punct ;",
- "id str", "punct =", """string '"'""", "punct ;",
- ]),
-
+ (
+ r"""
+ rexl.re = {
+ NAME: /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/,
+ UNQUOTED_LITERAL: /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/,
+ QUOTED_LITERAL: /^'(?:[^']|'')*'/,
+ NUMERIC_LITERAL: /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/,
+ SYMBOL: /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/
+ };
+ """, # NOQA
+ [
+ "id rexl", "punct .", "id re", "punct =", "punct {",
+ "id NAME", "punct :", r"""regex /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/""", "punct ,",
+ "id UNQUOTED_LITERAL", "punct :", r"""regex /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/""",
+ "punct ,",
+ "id QUOTED_LITERAL", "punct :", r"""regex /^'(?:[^']|'')*'/""", "punct ,",
+ "id NUMERIC_LITERAL", "punct :", r"""regex /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/""", "punct ,",
+ "id SYMBOL", "punct :", r"""regex /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/""", # NOQA
+ "punct }", "punct ;"
+ ],
+ ),
+ (
+ r"""
+ rexl.re = {
+ NAME: /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/,
+ UNQUOTED_LITERAL: /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/,
+ QUOTED_LITERAL: /^'(?:[^']|'')*'/,
+ NUMERIC_LITERAL: /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/,
+ SYMBOL: /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/
+ };
+ str = '"';
+ """, # NOQA
+ [
+ "id rexl", "punct .", "id re", "punct =", "punct {",
+ "id NAME", "punct :", r"""regex /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/""", "punct ,",
+ "id UNQUOTED_LITERAL", "punct :", r"""regex /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/""",
+ "punct ,",
+ "id QUOTED_LITERAL", "punct :", r"""regex /^'(?:[^']|'')*'/""", "punct ,",
+ "id NUMERIC_LITERAL", "punct :", r"""regex /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/""", "punct ,",
+ "id SYMBOL", "punct :", r"""regex /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/""", # NOQA
+ "punct }", "punct ;",
+ "id str", "punct =", """string '"'""", "punct ;",
+ ],
+ ),
(r""" this._js = "e.str(\"" + this.value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\")"; """,
["keyword this", "punct .", "id _js", "punct =", r'''string "e.str(\""''', "punct +", "keyword this",
"punct .", "id value", "punct .", "id replace", "punct (", r"regex /\\/g", "punct ,", r'string "\\\\"',