diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-02-03 21:34:09 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-02-03 21:34:09 -0700 |
| commit | 2521afef699d40917db906ebb27a87c5ea287fbe (patch) | |
| tree | a42906cf33e4199b81f8aba70153120cd4aa5c0f /test/run_tests.cpp | |
| parent | 5c310f43432ec723f8b7d449313c1ea20f1f2d78 (diff) | |
| download | zig-2521afef699d40917db906ebb27a87c5ea287fbe.tar.gz zig-2521afef699d40917db906ebb27a87c5ea287fbe.zip | |
add ability to call function pointer field
also introduce the self hosted tests
closes #108
Diffstat (limited to 'test/run_tests.cpp')
| -rw-r--r-- | test/run_tests.cpp | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp index f3a7145f17..3f9eafcda0 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -25,6 +25,7 @@ struct TestCase { ZigList<const char *> compiler_args; ZigList<const char *> program_args; bool is_parseh; + bool is_self_hosted; }; static ZigList<TestCase*> test_cases = {0}; @@ -157,21 +158,6 @@ fn this_is_a_function() -> unreachable { } )SOURCE", "OK\n"); - add_simple_case("comments", R"SOURCE( -import "std.zig"; - -/** - * multi line doc comment - */ -fn another_function() {} - -/// this is a documentation comment -/// doc comment line 2 -pub fn main(args: [][]u8) -> %void { - %%stdout.printf(/* mid-line comment /* nested */ */ "OK\n"); -} - )SOURCE", "OK\n"); - { TestCase *tc = add_simple_case("multiple files with private function", R"SOURCE( import "std.zig"; @@ -2205,6 +2191,30 @@ extern void (*fn_ptr)(void); })SOURCE"); } +static void run_self_hosted_test(void) { + Buf zig_stderr = BUF_INIT; + Buf zig_stdout = BUF_INIT; + int return_code; + ZigList<const char *> args = {0}; + args.append("test"); + args.append("../test/self_hosted.zig"); + os_exec_process(zig_exe, args, &return_code, &zig_stderr, &zig_stdout); + + if (return_code) { + printf("\nSelf-hosted tests failed:\n"); + printf("./zig test ../test/self_hosted.zig\n"); + printf("%s\n", buf_ptr(&zig_stderr)); + exit(1); + } +} + +static void add_self_hosted_tests(void) { + TestCase *test_case = allocate<TestCase>(1); + test_case->case_name = "self hosted tests"; + test_case->is_self_hosted = true; + test_cases.append(test_case); +} + static void print_compiler_invocation(TestCase *test_case) { printf("%s", zig_exe); for (int i = 0; i < test_case->compiler_args.length; i += 1) { @@ -2214,6 +2224,10 @@ static void print_compiler_invocation(TestCase *test_case) { } static void run_test(TestCase *test_case) { + if (test_case->is_self_hosted) { + return run_self_hosted_test(); + } + for (int i = 0; i < test_case->source_files.length; i += 1) { TestSourceFile *test_source = &test_case->source_files.at(i); os_write_file( @@ -2359,6 +2373,7 @@ int main(int argc, char **argv) { add_compiling_test_cases(); add_compile_failure_test_cases(); add_parseh_test_cases(); + add_self_hosted_tests(); run_all_tests(reverse); cleanup(); } |
