From a5c2de5fee67e35c8173b7051675d49648086cbb Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 28 Jan 2016 20:26:40 -0700 Subject: ability to specify function type closes #14 --- test/run_tests.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/run_tests.cpp') 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'"); } ////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3