Exemple #1
0
def test_fcode_For():
    x, y = symbols('x y')

    f = For(x, Range(0, 10, 2), [Assignment(y, x * y)])
    sol = fcode(f)
    assert sol == ("      do x = 0, 10, 2\n"
                   "         y = x*y\n"
                   "      end do")
Exemple #2
0
def test_ccode_For():
    f = For(x, Range(0, 10, 2), [aug_assign(y, '*', x)])
    assert ccode(f) == ("for (x = 0; x < 10; x += 2) {\n" "   y *= x;\n" "}")
Exemple #3
0
def test_rcode_For():
    f = For(x, Range(0, 10, 2), [aug_assign(y, "*", x)])
    sol = rcode(f)
    assert sol == ("for (x = 0; x < 10; x += 2) {\n" "   y *= x;\n" "}")