From 4285a6745939a4dbc20e767ed2a40cd3b354727a Mon Sep 17 00:00:00 2001 From: Kris Chambers Date: Sun, 5 Jul 2020 13:16:26 -0400 Subject: [PATCH] Fix test for structs containing anon fn with optional void return types --- vlib/v/tests/struct_test.v | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/vlib/v/tests/struct_test.v b/vlib/v/tests/struct_test.v index 31163a664ef965..e5f1316252e133 100644 --- a/vlib/v/tests/struct_test.v +++ b/vlib/v/tests/struct_test.v @@ -314,18 +314,27 @@ fn test_struct_with_default_values_no_init() { assert s3.field_optional == 2 } -struct StructWithFnTypesWithVoidOptionReturnType { +struct FieldsWithOptionalVoidReturnType { f fn() ? + g fn() ? } -fn test_struct_with_fn_types_with_optional_void_return() ? { - s := StructWithFnTypesWithVoidOptionReturnType { +fn test_fields_anon_fn_with_optional_void_return_type() { + foo := FieldsWithOptionalVoidReturnType { f: fn() ? { - assert true - return none + return error("oops") } + g: fn() ? { + return + } + } + + foo.f() or { + assert err == "oops" } - s.f() + foo.g() or { + assert false + } }