From d4ffed89c0c2af08e3d3fcb293f1afe8146ce250 Mon Sep 17 00:00:00 2001 From: lydiandy <56576373+lydiandy@users.noreply.github.com> Date: Tue, 25 Feb 2020 18:14:59 +0800 Subject: [PATCH] add typeof test for fn (#3832) --- vlib/compiler/tests/typeof_test.v | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vlib/compiler/tests/typeof_test.v b/vlib/compiler/tests/typeof_test.v index b3a1712a20..1c12c6817e 100644 --- a/vlib/compiler/tests/typeof_test.v +++ b/vlib/compiler/tests/typeof_test.v @@ -72,3 +72,16 @@ fn test_typeof_on_sumtypes_of_structs() { assert typeof(c) == 'BoolExpr' assert typeof(d) == 'UnaryExpr' } + +type MyFn fn(int) int +type MyFn2 fn() + +fn myfn(i int) int { + return i +} +fn myfn2() {} + +fn test_typeof_on_fn() { + assert typeof(myfn) == 'fn (int) int' + assert typeof(myfn2) == 'fn ()' +} \ No newline at end of file