示例#1
0
void Branch__get_static_errors_formatted(caStack* stack)
{
    Branch* branch = as_branch(circa_input(stack, 0));
    if (branch == NULL)
        return circa_output_error(stack, "NULL branch");

    if (is_null(&branch->staticErrors))
        set_list(circa_output(stack, 0), 0);

    caValue* errors = &branch->staticErrors;
    caValue* out = circa_output(stack, 0);
    set_list(out, circa_count(errors));
    for (int i=0; i < circa_count(out); i++)
        format_static_error(circa_index(errors, i), circa_index(out, i));
}
示例#2
0
void Block__get_static_errors_formatted(VM* vm)
{
    Block* block = as_block(vm->input(0));
    if (block == NULL)
        return vm->throw_str("NULL block");

    Value* errors = block_get_static_errors(block);
    if (errors == NULL) {
        set_list(vm->output(), 0);
        return;
    }

    Value* out = vm->output();
    set_list(out, circa_count(errors));
    for (int i=0; i < circa_count(out); i++)
        format_static_error(circa_index(errors, i), circa_index(out, i));
}
示例#3
0
void test_assert_function(Term* term, int line, const char* file)
{
    if (term == NULL) {
        std::cout << "NULL term in " << file << ", line " << line << std::endl;
        declare_current_test_failed();
        return;
    }

    if (has_static_error(term)) {
        std::cout << "Compile error on term " << global_id(term) << std::endl;
        Value str;
        format_static_error(term, &str);
        std::cout << as_cstring(&str) << std::endl;
        std::cout << "Occurred in " << file << ", line " << line << std::endl;
        declare_current_test_failed();
    }

    if (is_bool(term_value(term)) && !as_bool(term_value(term))) {
        std::cout << "Assertion failed: " << term->id << std::endl;
        std::cout << "Occurred in " << file << ", line " << line << std::endl;
        declare_current_test_failed();
    }
}