Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / third_party / cython / src / Cython / Build / Tests / TestStripLiterals.py
blobca8e6a7d1456b05cfbfc795c71e3be27d560f0f2
1 from Cython.Build.Dependencies import strip_string_literals
3 from Cython.TestUtils import CythonTest
5 class TestStripLiterals(CythonTest):
7 def t(self, before, expected):
8 actual, literals = strip_string_literals(before, prefix="_L")
9 self.assertEquals(expected, actual)
10 for key, value in literals.items():
11 actual = actual.replace(key, value)
12 self.assertEquals(before, actual)
14 def test_empty(self):
15 self.t("", "")
17 def test_single_quote(self):
18 self.t("'x'", "'_L1_'")
20 def test_double_quote(self):
21 self.t('"x"', '"_L1_"')
23 def test_nested_quotes(self):
24 self.t(""" '"' "'" """, """ '_L1_' "_L2_" """)
26 def test_triple_quote(self):
27 self.t(" '''a\n''' ", " '''_L1_''' ")
29 def test_backslash(self):
30 self.t(r"'a\'b'", "'_L1_'")
31 self.t(r"'a\\'", "'_L1_'")
32 self.t(r"'a\\\'b'", "'_L1_'")
34 def test_unicode(self):
35 self.t("u'abc'", "u'_L1_'")
37 def test_raw(self):
38 self.t(r"r'abc\\'", "r'_L1_'")
40 def test_raw_unicode(self):
41 self.t(r"ru'abc\\'", "ru'_L1_'")
43 def test_comment(self):
44 self.t("abc # foo", "abc #_L1_")
46 def test_comment_and_quote(self):
47 self.t("abc # 'x'", "abc #_L1_")
48 self.t("'abc#'", "'_L1_'")
50 def test_include(self):
51 self.t("include 'a.pxi' # something here",
52 "include '_L1_' #_L2_")
54 def test_extern(self):
55 self.t("cdef extern from 'a.h': # comment",
56 "cdef extern from '_L1_': #_L2_")