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

Unified Diff: third_party/cython/src/Cython/Build/Tests/TestInline.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/Build/Tests/TestInline.py
diff --git a/third_party/cython/src/Cython/Build/Tests/TestInline.py b/third_party/cython/src/Cython/Build/Tests/TestInline.py
new file mode 100644
index 0000000000000000000000000000000000000000..54fffcb9f99258d4296d9f6b9a697b387842fd91
--- /dev/null
+++ b/third_party/cython/src/Cython/Build/Tests/TestInline.py
@@ -0,0 +1,59 @@
+import os, tempfile
+from Cython.Shadow import inline
+from Cython.Build.Inline import safe_type
+from Cython.TestUtils import CythonTest
+
+try:
+ import numpy
+ has_numpy = True
+except:
+ has_numpy = False
+
+test_kwds = dict(force=True, quiet=True)
+
+global_value = 100
+
+class TestInline(CythonTest):
+ def setUp(self):
+ CythonTest.setUp(self)
+ self.test_kwds = dict(test_kwds)
+ if os.path.isdir('BUILD'):
+ lib_dir = os.path.join('BUILD','inline')
+ else:
+ lib_dir = tempfile.mkdtemp(prefix='cython_inline_')
+ self.test_kwds['lib_dir'] = lib_dir
+
+ def test_simple(self):
+ self.assertEquals(inline("return 1+2", **self.test_kwds), 3)
+
+ def test_types(self):
+ self.assertEquals(inline("""
+ cimport cython
+ return cython.typeof(a), cython.typeof(b)
+ """, a=1.0, b=[], **self.test_kwds), ('double', 'list object'))
+
+ def test_locals(self):
+ a = 1
+ b = 2
+ self.assertEquals(inline("return a+b", **self.test_kwds), 3)
+
+ def test_globals(self):
+ self.assertEquals(inline("return global_value + 1", **self.test_kwds), global_value + 1)
+
+ def test_pure(self):
+ import cython as cy
+ b = inline("""
+ b = cy.declare(float, a)
+ c = cy.declare(cy.pointer(cy.float), &b)
+ return b
+ """, a=3)
+ self.assertEquals(type(b), float)
+
+ if has_numpy:
+
+ def test_numpy(self):
+ import numpy
+ a = numpy.ndarray((10, 20))
+ a[0,0] = 10
+ self.assertEquals(safe_type(a), 'numpy.ndarray[numpy.float64_t, ndim=2]')
+ self.assertEquals(inline("return a[0,0]", a=a, **self.test_kwds), 10.0)
« no previous file with comments | « third_party/cython/src/Cython/Build/Inline.py ('k') | third_party/cython/src/Cython/Build/Tests/TestStripLiterals.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698