Exemple #1
0
    def test_join_between_same_types_results_in_same_value(
            self, val1: PythonValue, val2: PythonValue) -> None:
        joined1 = val1.join(val2)
        joined2 = val2.join(val1)

        if val1.is_top() or val2.is_top():
            assert joined1.is_top()
            assert joined2.is_top()
        else:
            assert joined1.is_top() != isinstance(val1.val, type(val2.val))
            assert joined2.is_top() != isinstance(val1.val, type(val2.val))

        assert joined1 == joined2
Exemple #2
0
    def test_running_if_with_booltop_is_the_same_as_joining_noelse(
            self, i: PythonValue, j: PythonValue) -> None:
        """
        This test simulates the transformation of the following piece of code:

        > b = 2
        > if d:
        >    b = 5
        """

        st = pt.Store()

        st['b'] = i

        def if_(st):
            # type: (Store) -> Store
            st['b'] = j
            return st

        if_qst = st['d']

        st = pt.runIf(st, if_qst, if_)

        val_b = st['b']

        assert val_b == i.join(j)
Exemple #3
0
    def test_join_to_top_is_always_top(self, val: PythonValue) -> None:
        top = PythonValue.top()
        joined1 = top.join(val)
        joined2 = val.join(top)

        assert joined1.is_top()
        assert joined2.is_top()
        assert joined1 == joined2