Beispiel #1
0
def test_random():
    for i in range(100):
        x = run_flo("(random)")
        assert 0.0 <= x < 1.0
        x = run_fix("(random %s)" % (5 + i))
        if pytest.config.new_pycket:
            assert 0 <= x.value < i + 5
        else:
            assert 0 <= x < i + 5
Beispiel #2
0
def test_arithmetic():
    run_fix("(+ )", 0)
    run_fix("(+ 1)", 1)
    run_fix("(+ 2 3)", 5)
    run_fix("(+ 2 3 4)", 9)

    with pytest.raises(SchemeException):
        run_fix("(- )", 0)
    run_fix("(- 1)", -1)
    run_fix("(- 2 3)", -1)
    run_fix("(- 2 3 4)", -5)

    run_fix("(* )", 1)
    run_fix("(* 2)", 2)
    run_fix("(* 2 3)", 6)
    run_fix("(* 2 3 4)", 24)

    with pytest.raises(SchemeException):
        run_flo("(/ )", 0)
    run_flo("(/ 2.0)", 0.5)
    run_flo("(/ 2. 3.)", 2. / 3.)
    run_flo("(/ 2. 3. 4.)", 2. / 3. / 4.)
Beispiel #3
0
def test_arithmetic():
    run_fix("(+ )", 0)
    run_fix("(+ 1)", 1)
    run_fix("(+ 2 3)", 5)
    run_fix("(+ 2 3 4)", 9)

    with pytest.raises(SchemeException):
        run_fix("(- )", 0)
    run_fix("(- 1)", -1)
    run_fix("(- 2 3)", -1)
    run_fix("(- 2 3 4)", -5)

    run_fix("(* )", 1)
    run_fix("(* 2)", 2)
    run_fix("(* 2 3)", 6)
    run_fix("(* 2 3 4)", 24)

    with pytest.raises(SchemeException):
        run_flo("(/ )", 0)
    run_flo("(/ 2.0)", 0.5)
    run_flo("(/ 2. 3.)", 2. / 3.)
    run_flo("(/ 2. 3. 4.)", 2. / 3. / 4.)
Beispiel #4
0
def test_random():
    for i in range(100):
        x = run_flo("(random)")
        assert 0.0 <= x < 1.0
        x = run_fix("(random %s)" % (5 + i))
        assert 0 <= x < i + 5
Beispiel #5
0
def test_random():
    for i in range(100):
        x = run_flo("(random)")
        assert 0.0 <= x < 1.0
        x = run_fix("(random %s)" % (5 + i))
        assert 0 <= x < i + 5