[pypy-commit] pypy union-side-effects: Add an elementary (but failing) hypothesis test for union()
rlamy
pypy.commits at gmail.com
Fri Sep 2 22:42:44 EDT 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: union-side-effects
Changeset: r86850:34fcf0746426
Date: 2016-09-03 01:24 +0100
http://bitbucket.org/pypy/pypy/changeset/34fcf0746426/
Log: Add an elementary (but failing) hypothesis test for union()
diff --git a/rpython/annotator/test/test_model.py b/rpython/annotator/test/test_model.py
--- a/rpython/annotator/test/test_model.py
+++ b/rpython/annotator/test/test_model.py
@@ -1,5 +1,8 @@
import pytest
+from hypothesis import given
+from hypothesis import strategies as st
+
from rpython.flowspace.model import Variable
from rpython.flowspace.operation import op
from rpython.translator.translator import TranslationContext
@@ -102,6 +105,21 @@
assert f2.contains(f1)
assert f1.contains(f2)
+def const_int(n):
+ s = SomeInteger(nonneg=(n>=0))
+ s.const = n
+ return s
+
+st_int = st.one_of(st.builds(SomeInteger, st.booleans(), st.booleans()),
+ st.builds(const_int, st.integers()))
+st_annotation = st_int
+
+ at given(s=st_annotation)
+def test_union_unary(s):
+ assert union(s, s) == s
+ assert union(s_ImpossibleValue, s) == s
+
+
def compile_function(function, annotation=[]):
t = TranslationContext()
t.buildannotator().build_types(function, annotation)
More information about the pypy-commit
mailing list