Skip to content

Instantly share code, notes, and snippets.

@smarr
Created September 24, 2014 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smarr/2f90f43bcbd9e17c3617 to your computer and use it in GitHub Desktop.
Save smarr/2f90f43bcbd9e17c3617 to your computer and use it in GitHub Desktop.
diff -r ae1f561d0a35 rpython/translator/c/test/test_typed.py
--- a/rpython/translator/c/test/test_typed.py Tue Sep 23 15:29:32 2014 -0400
+++ b/rpython/translator/c/test/test_typed.py Wed Sep 24 11:39:30 2014 +0200
@@ -487,6 +487,14 @@
fn = self.getcompiled(snippet.lshift_func, [int])
fn(1, expected_exception_name='OverflowError')
+ fn2 = self.getcompiled(snippet.lshift_func_2, [int, int])
+
+ assert fn2(1, 32) == 4294967296
+ assert fn2(1, 60) == 1152921504606846976
+
+ fn2(1152921504606846976, 10, expected_exception_name='OverflowError')
+ fn2(1, 170, expected_exception_name='OverflowError')
+
def test_int_unary_ovf(self):
def w(a, b):
if not b:
diff -r ae1f561d0a35 rpython/translator/test/snippet.py
--- a/rpython/translator/test/snippet.py Tue Sep 23 15:29:32 2014 -0400
+++ b/rpython/translator/test/snippet.py Wed Sep 24 11:39:30 2014 +0200
@@ -1110,6 +1110,13 @@
except (hugelmugel, OverflowError, StandardError, ValueError):
raise
+def lshift_func_2(x=numtype, y=numtype):
+ try:
+ return ovfcheck(x << y)
+ except (OverflowError, StandardError, ValueError):
+ raise
+
+
def unary_func(i=numtype):
try:
return ovfcheck(-i), ovfcheck(abs(i-1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment