From 1958ff49f84bb3d762bfd3e6c3fb51d29f1f34ef Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Mon, 29 Nov 2021 14:09:48 +0000 Subject: [PATCH] ok yeah that's good type inference thank you --- opt/opt_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/opt/opt_test.go b/opt/opt_test.go index 543412a..b567b39 100644 --- a/opt/opt_test.go +++ b/opt/opt_test.go @@ -66,3 +66,30 @@ func TestBind(t *testing.T) { } }) } + +func TestNew(t *testing.T) { + count := Bind(utf8.RuneCountInString) + + getCity := func(name string) (string, bool) { + if name == "Jordan" { + return "Chicago", true + } + return "", false + } + + if n, ok := count(New(getCity("Jordan"))).Open(); !ok { + t.Errorf("should be ok") + } else { + if n != 7 { + t.Errorf("what") + } + } + + if n, ok := count(New(getCity("poopface jones"))).Open(); ok { + t.Errorf("should not be ok") + } else { + if n != 0 { + t.Errorf("why do we have this value %d", n) + } + } +}