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

Unified Diff: third_party/cython/src/Cython/Tests/TestStringIOTree.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 side-by-side diff with in-line comments
Download patch
Index: third_party/cython/src/Cython/Tests/TestStringIOTree.py
diff --git a/third_party/cython/src/Cython/Tests/TestStringIOTree.py b/third_party/cython/src/Cython/Tests/TestStringIOTree.py
new file mode 100644
index 0000000000000000000000000000000000000000..09c04a514146a846efbe79d4f68bcb164cb620be
--- /dev/null
+++ b/third_party/cython/src/Cython/Tests/TestStringIOTree.py
@@ -0,0 +1,67 @@
+import unittest
+
+from Cython import StringIOTree as stringtree
+
+code = """
+cdef int spam # line 1
+
+cdef ham():
+ a = 1
+ b = 2
+ c = 3
+ d = 4
+
+def eggs():
+ pass
+
+cpdef bacon():
+ print spam
+ print 'scotch'
+ print 'tea?'
+ print 'or coffee?' # line 16
+"""
+
+linemap = dict(enumerate(code.splitlines()))
+
+class TestStringIOTree(unittest.TestCase):
+
+ def setUp(self):
+ self.tree = stringtree.StringIOTree()
+
+ def test_markers(self):
+ assert not self.tree.allmarkers()
+
+ def test_insertion(self):
+ self.write_lines((1, 2, 3))
+ line_4_to_6_insertion_point = self.tree.insertion_point()
+ self.write_lines((7, 8))
+ line_9_to_13_insertion_point = self.tree.insertion_point()
+ self.write_lines((14, 15, 16))
+
+ line_4_insertion_point = line_4_to_6_insertion_point.insertion_point()
+ self.write_lines((5, 6), tree=line_4_to_6_insertion_point)
+
+ line_9_to_12_insertion_point = (
+ line_9_to_13_insertion_point.insertion_point())
+ self.write_line(13, tree=line_9_to_13_insertion_point)
+
+ self.write_line(4, tree=line_4_insertion_point)
+ self.write_line(9, tree=line_9_to_12_insertion_point)
+ line_10_insertion_point = line_9_to_12_insertion_point.insertion_point()
+ self.write_line(11, tree=line_9_to_12_insertion_point)
+ self.write_line(10, tree=line_10_insertion_point)
+ self.write_line(12, tree=line_9_to_12_insertion_point)
+
+ self.assertEqual(self.tree.allmarkers(), range(1, 17))
+ self.assertEqual(code.strip(), self.tree.getvalue().strip())
+
+
+ def write_lines(self, linenos, tree=None):
+ for lineno in linenos:
+ self.write_line(lineno, tree=tree)
+
+ def write_line(self, lineno, tree=None):
+ if tree is None:
+ tree = self.tree
+ tree.markers.append(lineno)
+ tree.write(linemap[lineno] + '\n')
« no previous file with comments | « third_party/cython/src/Cython/Tests/TestCodeWriter.py ('k') | third_party/cython/src/Cython/Tests/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698