Author: Ronan Lamy <ronan.l...@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 + +@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) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit