diff options
author | Colin Kennedy <colinvfx@gmail.com> | 2019-12-04 23:16:02 -0800 |
---|---|---|
committer | Colin Kennedy <colinvfx@gmail.com> | 2019-12-04 23:16:02 -0800 |
commit | 39a007c8843809696f03f05612dec4433ac0cab4 (patch) | |
tree | 85fc5173b8530bdc1b78863994f8738863b56076 | |
parent | 276eac7704a2ef302378eeeb13117531f135bf44 (diff) | |
download | pygments-git-39a007c8843809696f03f05612dec4433ac0cab4.tar.gz |
Updated unittests to make sure outer-text-pair matches are not matched a string types
-rw-r--r-- | pygments/lexers/usd.py | 6 | ||||
-rw-r--r-- | tests/test_usd.py | 57 |
2 files changed, 58 insertions, 5 deletions
diff --git a/pygments/lexers/usd.py b/pygments/lexers/usd.py index cda37e42..4b2a56a5 100644 --- a/pygments/lexers/usd.py +++ b/pygments/lexers/usd.py @@ -116,10 +116,10 @@ class UsdLexer(RegexLexer): ("[-]?([0-9]*[.])?[0-9]+", Number), (r"'''(?:.|\n)*?'''", String), (r'"""(?:.|\n)*?"""', String), - (r"'.*'", String), - (r'".*"', String), + (r"'.*?'", String), + (r'".*?"', String), (r"<(\.\./)*([\w/]+|[\w/]+\.\w+[\w:]*)>", Name.Namespace), - (r"@.*@", String.Interpol), + (r"@.*?@", String.Interpol), (r'\(.*"[.\\n]*".*\)', String.Doc), (r"\A#usda .+$", Comment.Hashbang), (r"\s+", Text), diff --git a/tests/test_usd.py b/tests/test_usd.py index ff590dd3..3b2ecb20 100644 --- a/tests/test_usd.py +++ b/tests/test_usd.py @@ -38,7 +38,7 @@ class Features(_Common): "@./some/path/to/a/file/foo.usda@", "@/some/path/to/a/file/foo.usda@", "@some/path/to/a/file/foo.usda@", - r"@file://SPECI__Z-_ALIZED(syntax_here)?with_arbitrary@#)(%*&)\characters.tar.gz@", + r"@file://SPECI__Z-_ALIZED(syntax_here)?with_arbitrary#)(%*&)\characters.tar.gz@", ]: expected = [ (token.String.Interpol, path), @@ -392,7 +392,10 @@ class Features(_Common): (token.Token.Operator, u"="), (token.Token.Text, u" "), (token.Token.Punctuation, u"["), - (token.Token.Literal.String, u'"modelingVariant", "shadingComplexity"'), + (token.Token.Literal.String, u'"modelingVariant"'), + (token.Token.Generic, u','), + (token.Token.Text, u' '), + (token.Token.Literal.String, u'"shadingComplexity"'), (token.Token.Punctuation, u"]"), (token.Token.Text, u"\n"), (token.Token.Punctuation, u")"), @@ -524,3 +527,53 @@ class EdgeCases(_Common): ], self._get(code), ) + + def test_outer_match(self): + """Make sure that text between located between quotes and @@s are not matched.""" + at_sign = "@firststring@ something else @secondstring@" + + self.assertEqual( + [ + (token.Token.Literal.String.Interpol, u'@firststring@'), + (token.Token.Text, u' '), + (token.Token.Generic, u'something'), + (token.Token.Text, u' '), + (token.Token.Generic, u'else'), + (token.Token.Text, u' '), + (token.Token.Literal.String.Interpol, u'@secondstring@'), + (token.Token.Text, u'\n'), + ], + self._get(at_sign) + ) + + single = "'firststring' something else 'secondstring'" + + self.assertEqual( + [ + (token.Token.Literal.String, u"'firststring'"), + (token.Token.Text, u' '), + (token.Token.Generic, u'something'), + (token.Token.Text, u' '), + (token.Token.Generic, u'else'), + (token.Token.Text, u' '), + (token.Token.Literal.String, u"'secondstring'"), + (token.Token.Text, u'\n'), + ], + self._get(single) + ) + + double = "'firststring' something else 'secondstring'" + + self.assertEqual( + [ + (token.Token.Literal.String, u"'firststring'"), + (token.Token.Text, u' '), + (token.Token.Generic, u'something'), + (token.Token.Text, u' '), + (token.Token.Generic, u'else'), + (token.Token.Text, u' '), + (token.Token.Literal.String, u"'secondstring'"), + (token.Token.Text, u'\n'), + ], + self._get(double) + ) |