예제 #1
0
def test_sum_of_squares_C():
    """Test for C compiling \sum_{i=1}^N i*i"""
    dag = create_sum_squares()
    cp = CCodePrinter(dag)
    module_name = "ignition_sum_of_squares_c"
    module_path = cp.to_ctypes_module(module_name)
    sys.path.append(module_path)
    sum_of_squares = import_module(module_name)
    assert (sum_of_squares.sum_squares(4) == 30)
예제 #2
0
def test_sum_of_squares_C():
    """Test for C compiling \sum_{i=1}^N i*i"""
    dag = create_sum_squares()
    cp = CCodePrinter(dag)
    module_name = "ignition_sum_of_squares_c"
    module_path = cp.to_ctypes_module(module_name)
    sys.path.append(module_path)
    sum_of_squares = import_module(module_name)
    assert(sum_of_squares.sum_squares(4) == 30)
예제 #3
0
def test_index_variable_loop_C():
    dag = create_index_variable_loop()
    modname = "ignition_index_variable_loop_c"
    modpath = CCodePrinter(dag).to_ctypes_module(modname)
    sys.path.append(modpath)
    index_variable_loop = import_module(modname)
    assert (index_variable_loop.idx_loop_fun() == 45)
예제 #4
0
def test_double_sum_C():
    dag = create_double_sum()
    modname = "ignition_double_sum_c"
    modpath = CCodePrinter(dag).to_ctypes_module(modname)
    sys.path.append(modpath)
    double_sum = import_module(modname)
    assert (double_sum.double_sum(3) == 20)
예제 #5
0
def test_statement_C():
    dag = Statement('=', 'a', 'b')
    printer = CCodePrinter(dag)
    assert (printer.code_str() == "a = b;\n")
예제 #6
0
def test_statement_C():
    dag = Statement('=', 'a', 'b')
    printer = CCodePrinter(dag)
    assert(printer.code_str() == "a = b;\n")