// TestComposeFilter_Empty_Nothing func TestComposeFilter_Empty_Nothing(t *testing.T) { f := maybe.ComposeFilter() m := maybe.Nothing() b := f(m) assertFalse(t, b) }
// TestComposeFilter_True_Nothing func TestComposeFilter_True_Nothing(t *testing.T) { f := maybe.ComposeFilter(FilterTrue) m := maybe.Nothing() b := f(m) assertFalse(t, b) }
// TestComposeMap_Empty_Nothing func TestComposeMap_Empty_Nothing(t *testing.T) { f := maybe.ComposeMap() _m := maybe.Nothing() m := f(_m) assertNothing(t, m) }
// TestComposeMap_Increment_Nothing func TestComposeMap_Increment_Nothing(t *testing.T) { f := maybe.ComposeMap(increment) _m := maybe.Nothing() m := f(_m) assertNothing(t, m) }
// TestCall_Nothing func TestCall_Nothing(t *testing.T) { _m := maybe.Nothing() m := maybe.Call(MapAny_Echo, _m) assertNothing(t, m) }
// TestCall_Multi_Nil func TestCall_Multi_Nil(t *testing.T) { arg1 := maybe.New("one") arg2 := maybe.Nothing() m := maybe.Call(MultiArgs_Last, arg1, arg2) assertNothing(t, m) }
// TestFilter_Nothing_Nil func TestFilter_Nothing_Nil(t *testing.T) { _m := maybe.Nothing() m := _m.Filter(nil) assertNothing(t, m) }
// TestFilter_Nothing_Panic func TestFilter_Nothing_Panic(t *testing.T) { _m := maybe.Nothing() m := _m.Filter(FilterPanic) assertNothing(t, m) }
// TestMap_Nothing_Nil func TestMap_Nothing_Nil(t *testing.T) { _m := maybe.Nothing() m := _m.Map(nil) assertNothing(t, m) }
// TestMap_Nothing_Panic func TestMap_Nothing_Panic(t *testing.T) { _m := maybe.Nothing() m := _m.Map(MapPanic) assertNothing(t, m) }
// TestGetOrElse_Nothing func TestGetOrElse_Nothing(t *testing.T) { m := maybe.Nothing() assertGetOrElse(t, m, ELSE, ELSE) }
// TestGetOrNil_Nothing func TestGetOrNil_Nothing(t *testing.T) { m := maybe.Nothing() assertGetOrNil(t, m, nil) }
// TestNothing func TestNothing(t *testing.T) { m := maybe.Nothing() assertNothing(t, m) }
// MapNothing func MapNothing(m *maybe.T) *maybe.T { return maybe.Nothing() }
*********************************************************************/ const ( ELSE = "else" ERROR_MSG = "error message" FILTER_PANIC = "filter_panic" MAP_PANIC = "map_panic" MAPPED = "mapped" SOMETHING = "something" FILTER_FUNC_ERR = "maybe.T.Filter() expects func with single return value of type bool" MAP_FUNC_ERR = "maybe.T.Map() expects func" MAP_FUNC_RET_ERR = "maybe.T.Map() expects return types to be one of: (any), (any, bool), (any, error)" CALL_FUNC_ERR = "maybe.Call() expects func" ) var nothing = maybe.Nothing() /********************************************************************* ** Test Assert Functions *********************************************************************/ // assertNothing func assertNothing(t *testing.T, m *maybe.T) { if m != nothing { t.Fatal("AssertNothing: m is not equal to maybe.Nothing()") } _, ok := m.Get() if ok { t.Fatal("assertNothing: m.Get() returned true") } err := m.Err()