예제 #1
0
def test_int_values():
    v = Int().values(30, 20, 10)
    result = Qit().run(v.iterate())
    assert result == [30, 20, 10]

    result = Qit().run(v.generate().take(100))
    for i in result:
        assert i in (30, 20, 10)
예제 #2
0
def test_values_int_variable():
    ctx = Qit()
    x = Variable(Int(), "x")
    y = Variable(Int(), "y")

    r = Int().values(x, 7, y)
    result = ctx.run(r.iterate(), args={"x": 2, "y": 11})
    assert result == [2, 7, 11]
예제 #3
0
파일: test_domain.py 프로젝트: spirali/qit
def test_domain_constant_generator():
    c = Qit()
    s = Int() * Int()
    f = s.value((7, 8)).make_function()
    d = Domain(Int(), generator=f())

    result = c.run(d.generate().take(5))
    assert result == [ (7, 8) ] * 5
예제 #4
0
파일: test_struct.py 프로젝트: spirali/qit
def test_struct_constructor():
    ctx = Qit()
    x = Variable(Int(), "x")
    s = Int() * Int() * Int()
    result = ctx.run(s.value((x, 10, x)), args={x: 11})
    assert result == (11, 10, 11)
예제 #5
0
def test_values_int_empty():
    v = Int().values()
    result = Qit().run(v.iterate())
    assert result == []