Commits

Alex Gaynor committed 6bb684c Draft

make this test almost pass

Comments (0)

Files changed (1)

pypy/rlib/test/test_rrandom.py

+import _random
+
+from pypy.rlib.rarithmetic import intmask
 from pypy.rlib.rrandom import Random, N, r_uint
-from pypy.rlib.rarithmetic import intmask
-import _random
+from pypy.translator.c.test.test_genc import compile
 
 # the numbers were created by using CPython's _randommodule.c
 
     cpyrandom.jumpahead(100)
     assert tuple(rnd.state) + (rnd.index, ) == cpyrandom.getstate()
 
+
 def test_translate():
-    from pypy.translator.interactive import Translation
     def f(x, y):
+        x = r_uint(x)
+        y = r_uint(y)
         rnd = Random(x)
         rnd.init_by_array([x, y])
         rnd.jumpahead(intmask(y))
-        return rnd.genrand32(), rnd.random()
-    t = Translation(f)
-    fc = t.compile_c([r_uint, r_uint])
-    assert fc(r_uint(1), r_uint(2)) == f(r_uint(1), r_uint(2))
+        return float(rnd.genrand32()) + rnd.random()
+    fc = compile(f, [int, int])
+    assert fc(1, 2) == f(1, 2)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.