Exemplo n.º 1
0
def test_compatible_to_vector():
    v = Vec3(Vec2(1, 2))
    assert v == (1, 2, 0)

    v = Vec2(Vec3(1, 2, 3))
    assert v.x == 1
    assert v.y == 2
Exemplo n.º 2
0
def test_deep_copy():
    import copy

    v = Vec2(1, 2)
    l1 = [v, v, v]
    l2 = copy.copy(l1)
    assert l2[0] is l2[1]
    assert l2[1] is l2[2]
    assert l2[0] is v

    # Vec3, CVec2 and CVec3 are immutable and do not create copies of itself!
    l3 = copy.deepcopy(l1)
    assert l3[0] is l3[1]
    assert l3[1] is l3[2]
    assert l3[0] is not v
Exemplo n.º 3
0
def test_isub_vector(vec2):
    v = Vec2(2, 3)
    v -= Vec2(7, 7)
    assert v == (-5, -4)
Exemplo n.º 4
0
def test_init_vec2(vcls):
    v = Vec2(vcls(2, 3))
    assert v.x == 2
    assert v.y == 3
Exemplo n.º 5
0
def test_iadd_vector(vec2):
    v = Vec2(2, 3)
    v += Vec2(7, 7)
    assert v == (9, 10)