Skip to content

Commit

Permalink
Fix test for structs containing anon fn with optional void return types
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisChambers committed Jul 5, 2020
1 parent aa59dc5 commit 4285a67
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions vlib/v/tests/struct_test.v
Expand Up @@ -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
}
}

0 comments on commit 4285a67

Please sign in to comment.