diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-01-28 20:26:40 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-01-28 20:26:40 -0700 |
| commit | a5c2de5fee67e35c8173b7051675d49648086cbb (patch) | |
| tree | e6ee63d6daca6d6456e58f866d47e2c426cd9315 /test | |
| parent | 2bb2e61ee288a02e184e5b8422859a4afcbb4813 (diff) | |
| download | zig-a5c2de5fee67e35c8173b7051675d49648086cbb.tar.gz zig-a5c2de5fee67e35c8173b7051675d49648086cbb.zip | |
ability to specify function type
closes #14
Diffstat (limited to 'test')
| -rw-r--r-- | test/run_tests.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp index 940c92769c..6fa6e2eed9 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -1866,6 +1866,23 @@ fn f(i32) {} )SOURCE", 2, ".tmp_source.zig:2:1: error: missing function name", ".tmp_source.zig:3:6: error: missing parameter name"); + + add_compile_fail_case("wrong function type", R"SOURCE( +const fns = []fn(){ a, b, c }; +fn a() -> i32 {0} +fn b() -> i32 {1} +fn c() -> i32 {2} + )SOURCE", 3, + ".tmp_source.zig:2:21: error: expected type 'fn()', got 'fn() -> i32'", + ".tmp_source.zig:2:24: error: expected type 'fn()', got 'fn() -> i32'", + ".tmp_source.zig:2:27: error: expected type 'fn()', got 'fn() -> i32'"); + + add_compile_fail_case("extern function pointer mismatch", R"SOURCE( +const fns = [](fn(i32)->i32){ a, b, c }; +pub fn a(x: i32) -> i32 {x + 0} +pub fn b(x: i32) -> i32 {x + 1} +export fn c(x: i32) -> i32 {x + 2} + )SOURCE", 1, ".tmp_source.zig:2:37: error: expected type 'fn(i32) -> i32', got 'extern fn(i32) -> i32'"); } ////////////////////////////////////////////////////////////////////////////// |
