Exemplo n.º 1
0
def test_corner_cases():
    with pytest.raises(IndexError):
        EQ().stretch(1)[1]
    with pytest.raises(IndexError):
        (EQ() + RQ(1))[2]
    with pytest.raises(RuntimeError):
        mul(1, 1)
    with pytest.raises(RuntimeError):
        add(1, 1)
    with pytest.raises(RuntimeError):
        stretch(1, 1)
    with pytest.raises(RuntimeError):
        transform(1, 1)
    with pytest.raises(RuntimeError):
        differentiate(1, 1)
    with pytest.raises(RuntimeError):
        select(1, 1)
    with pytest.raises(RuntimeError):
        shift(1, 1)
    assert repr(EQ()) == str(EQ())
    assert EQ().__name__ == 'EQ'
    with pytest.raises(NotImplementedError):
        WrappedElement(1).display(1, lambda x: x)
    with pytest.raises(NotImplementedError):
        JoinElement(1, 2).display(1, 2, lambda x: x)
Exemplo n.º 2
0
def test_corner_cases():
    yield raises, IndexError, lambda: EQ().stretch(1)[1]
    yield raises, IndexError, lambda: (EQ() + RQ(1))[2]
    yield raises, RuntimeError, lambda: mul(1, 1)
    yield raises, RuntimeError, lambda: add(1, 1)
    yield raises, RuntimeError, lambda: stretch(1, 1)
    yield raises, RuntimeError, lambda: transform(1, 1)
    yield raises, RuntimeError, lambda: differentiate(1, 1)
    yield raises, RuntimeError, lambda: select(1, 1)
    yield raises, RuntimeError, lambda: shift(1, 1)
    yield eq, repr(EQ()), str(EQ())
    yield eq, EQ().__name__, 'EQ'
    yield raises, NotImplementedError, \
          lambda: WrappedElement(1).display(1, lambda x: x)
    yield raises, NotImplementedError, \
          lambda: JoinElement(1, 2).display(1, 2, lambda x: x)
Exemplo n.º 3
0
def shift(a, *shifts):
    return shift(a[0], *broadcast(operator.add, a.shifts, shifts))
Exemplo n.º 4
0
def reverse(a):
    return shift(reversed(a[0]), *reversed(a.shifts))