[pypy-svn] r43599 - in pypy/dist/pypy/rpython: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Thu May 24 16:06:39 CEST 2007


Author: cfbolz
Date: Thu May 24 16:06:39 2007
New Revision: 43599

Modified:
   pypy/dist/pypy/rpython/rbuiltin.py
   pypy/dist/pypy/rpython/test/test_rbuiltin.py
Log:
make min, max work for floats too.


Modified: pypy/dist/pypy/rpython/rbuiltin.py
==============================================================================
--- pypy/dist/pypy/rpython/rbuiltin.py	(original)
+++ pypy/dist/pypy/rpython/rbuiltin.py	Thu May 24 16:06:39 2007
@@ -233,11 +233,7 @@
     return vlist[0]
 
 def rtype_builtin_min(hop):
-    rint1, rint2 = hop.args_r
-    assert isinstance(rint1, IntegerRepr)
-    assert isinstance(rint2, IntegerRepr)
-    assert rint1.lowleveltype == rint2.lowleveltype
-    v1, v2 = hop.inputargs(rint1, rint2)
+    v1, v2 = hop.inputargs(hop.r_result, hop.r_result)
     return hop.gendirectcall(ll_min, v1, v2)
 
 def ll_min(i1, i2):
@@ -246,11 +242,7 @@
     return i2
 
 def rtype_builtin_max(hop):
-    rint1, rint2 = hop.args_r
-    assert isinstance(rint1, IntegerRepr)
-    assert isinstance(rint2, IntegerRepr)
-    assert rint1.lowleveltype == rint2.lowleveltype
-    v1, v2 = hop.inputargs(rint1, rint2)
+    v1, v2 = hop.inputargs(hop.r_result, hop.r_result)
     return hop.gendirectcall(ll_max, v1, v2)
 
 def ll_max(i1, i2):

Modified: pypy/dist/pypy/rpython/test/test_rbuiltin.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rbuiltin.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rbuiltin.py	Thu May 24 16:06:39 2007
@@ -113,6 +113,24 @@
         assert self.interpret(fn, (2, 2)) == 2
         assert self.interpret(fn, (-1, -12)) == -1
 
+    def test_float_min(self):
+        def fn(i, j):
+            return min(i, j)
+        assert self.interpret(fn, (1.9, 2.)) == 1.9
+        assert self.interpret(fn, (1.5, -1.4)) == -1.4
+
+    def test_float_int_min(self):
+        def fn(i, j):
+            return min(i, j)
+        assert self.interpret(fn, (1.9, 2)) == 1.9
+        assert self.interpret(fn, (1.5, -1)) == -1
+
+    def test_float_max(self):
+        def fn(i, j):
+            return max(i,j)
+        assert self.interpret(fn, (1.0, 2.)) == 2
+        assert self.interpret(fn, (1.1, -1)) == 1.1
+
     def test_builtin_math_floor(self):
         import math
         def fn(f):



More information about the Pypy-commit mailing list