Example #1
0
def test_ITE():
    expr = ITE(x < 1, y, z)
    assert rust_code(expr) == ("if (x < 1) {\n"
                               "    y\n"
                               "} else {\n"
                               "    z\n"
                               "}")
Example #2
0
def test_ITE():
    expr = ITE(x < 1, x, x + 2)
    assert rust_code(expr) == ("if (x < 1) {\n"
                               "    x\n"
                               "} else {\n"
                               "    x + 2\n"
                               "}")
Example #3
0
def test_ccode_ITE():
    expr = ITE(x < 1, y, z)
    assert ccode(expr) == ("((x < 1) ? (\n"
                           "   y\n"
                           ")\n"
                           ": (\n"
                           "   z\n"
                           "))")
Example #4
0
def test_ccode_ITE():
    expr = ITE(x < 1, x, x**2)
    assert ccode(expr) == ("((x < 1) ? (\n"
                           "   x\n"
                           ")\n"
                           ": (\n"
                           "   pow(x, 2)\n"
                           "))")
Example #5
0
def test_rcode_ITE():
    expr = ITE(x < 1, y, z)
    p = rcode(expr)
    ref="ifelse(x < 1,y,z)"
    assert p == ref
Example #6
0
def test_rcode_ITE():
    expr = ITE(x < 1, x, x**2)
    p = rcode(expr)
    ref="ifelse(x < 1,x,x^2)"
    assert p == ref