Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: third_party/cython/src/Cython/Build/Tests/TestStripLiterals.py

Issue 385073004: Adding cython v0.20.2 in third-party. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reference cython dev list thread. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 from Cython.Build.Dependencies import strip_string_literals
2
3 from Cython.TestUtils import CythonTest
4
5 class TestStripLiterals(CythonTest):
6
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)
13
14 def test_empty(self):
15 self.t("", "")
16
17 def test_single_quote(self):
18 self.t("'x'", "'_L1_'")
19
20 def test_double_quote(self):
21 self.t('"x"', '"_L1_"')
22
23 def test_nested_quotes(self):
24 self.t(""" '"' "'" """, """ '_L1_' "_L2_" """)
25
26 def test_triple_quote(self):
27 self.t(" '''a\n''' ", " '''_L1_''' ")
28
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_'")
33
34 def test_unicode(self):
35 self.t("u'abc'", "u'_L1_'")
36
37 def test_raw(self):
38 self.t(r"r'abc\\'", "r'_L1_'")
39
40 def test_raw_unicode(self):
41 self.t(r"ru'abc\\'", "ru'_L1_'")
42
43 def test_comment(self):
44 self.t("abc # foo", "abc #_L1_")
45
46 def test_comment_and_quote(self):
47 self.t("abc # 'x'", "abc #_L1_")
48 self.t("'abc#'", "'_L1_'")
49
50 def test_include(self):
51 self.t("include 'a.pxi' # something here",
52 "include '_L1_' #_L2_")
53
54 def test_extern(self):
55 self.t("cdef extern from 'a.h': # comment",
56 "cdef extern from '_L1_': #_L2_")
57
OLDNEW
« no previous file with comments | « third_party/cython/src/Cython/Build/Tests/TestInline.py ('k') | third_party/cython/src/Cython/Build/Tests/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698