Example #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)
Example #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]
Example #3
0
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
Example #4
0
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)
Example #5
0
def test_values_int_empty():
    v = Int().values()
    result = Qit().run(v.iterate())
    assert result == []