Exemplo n.º 1
0
// TestGetOrElse_Something
func TestGetOrElse_Something(t *testing.T) {
	m := maybe.New(SOMETHING)
	assertGetOrElse(t, m, ELSE, SOMETHING)
}
Exemplo n.º 2
0
// TestComposeMap_Increment_Double_Something
func TestComposeMap_Increment_Double_Something(t *testing.T) {
	f := maybe.ComposeMap(double, increment)
	_m := maybe.New(2)
	m := f(_m)
	assertSomethingValue(t, m, 6)
}
Exemplo n.º 3
0
// TestComposeFilter_True_Something
func TestComposeFilter_True_Something(t *testing.T) {
	f := maybe.ComposeFilter(FilterTrue)
	m := maybe.New(SOMETHING)
	b := f(m)
	assertTrue(t, b)
}
Exemplo n.º 4
0
// 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)
}
Exemplo n.º 5
0
// TestComposeMap_Empty_Something
func TestComposeMap_Empty_Something(t *testing.T) {
	f := maybe.ComposeMap()
	_m := maybe.New(SOMETHING)
	m := f(_m)
	assertSomething(t, m)
}
Exemplo n.º 6
0
// TestCall_Something_Echo
func TestCall_Something_Echo(t *testing.T) {
	_m := maybe.New(SOMETHING)
	m := maybe.Call(MapAny_Echo, _m)
	assertSomething(t, m)
}
Exemplo n.º 7
0
// TestCall_Multi_Something_Last
func TestCall_Multi_Something_Last(t *testing.T) {
	arg1 := maybe.New("one")
	arg2 := maybe.New("two")
	m := maybe.Call(MultiArgs_Last, arg1, arg2)
	assertSomethingValue(t, m, "two")
}
Exemplo n.º 8
0
// TestMap_Something_Any_Something
func TestMap_Something_Any_Something(t *testing.T) {
	_m := maybe.New(SOMETHING)
	m := _m.Map(MapAny_Echo)
	assertSomething(t, m)
}
Exemplo n.º 9
0
// TestMap_Something_Ok_False
func TestMap_Something_Ok_False(t *testing.T) {
	_m := maybe.New(SOMETHING)
	m := _m.Map(MapOk_False)
	assertNothing(t, m)
}
Exemplo n.º 10
0
// TestMap_Something_Nothing
func TestMap_Something_Nothing(t *testing.T) {
	_m := maybe.New(SOMETHING)
	m := _m.Map(MapNothing)
	assertNothing(t, m)
}
Exemplo n.º 11
0
// TestMap_Something_Something
func TestMap_Something_Something(t *testing.T) {
	_m := maybe.New(SOMETHING)
	m := _m.Map(MapSomething)
	assertSomethingValue(t, m, MAPPED)
}
Exemplo n.º 12
0
// TestMap_Something_NonFunc
func TestMap_Something_NonFunc(t *testing.T) {
	m := maybe.New(SOMETHING)
	f := func() { m.Map(0) } // int 0 is not a func
	assertPanic(t, f, MAP_FUNC_ERR)
}
Exemplo n.º 13
0
// TestMap_Something_NoReturn
func TestMap_Something_NoReturn(t *testing.T) {
	m := maybe.New(SOMETHING)
	f := func() { m.Map(Map_NoReturn) }
	assertPanic(t, f, MAP_FUNC_RET_ERR)
}
Exemplo n.º 14
0
// TestMap_Something_Nil
func TestMap_Something_Nil(t *testing.T) {
	m := maybe.New(SOMETHING)
	f := func() { m.Map(nil) }
	assertPanic(t, f, MAP_FUNC_ERR)
}
Exemplo n.º 15
0
// TestFilter_Something_NoReturn
func TestFilter_Something_NoReturn(t *testing.T) {
	m := maybe.New(SOMETHING)
	f := func() { m.Filter(Filter_NoReturn) }
	assertPanic(t, f, FILTER_FUNC_ERR)
}
Exemplo n.º 16
0
// TestMap_Something_Err_Panic
func TestMap_Something_Err_Panic(t *testing.T) {
	m := maybe.New(SOMETHING)
	f := func() { m.Map(MapErr_Panic) }
	assertPanic(t, f, MAP_PANIC)
}
Exemplo n.º 17
0
// TestFilter_Multi_Something_True_True
func TestFilter_Multi_Something_True_True(t *testing.T) {
	_m := maybe.New(SOMETHING)
	m := _m.Filter(FilterTrue).Filter(FilterTrue)
	assertSomething(t, m)
}
Exemplo n.º 18
0
// TestMap_Something_Err_Err
func TestMap_Something_Err_Err(t *testing.T) {
	_m := maybe.New(SOMETHING)
	m := _m.Map(MapErr_Err)
	assertError(t, m, ERROR_MSG)
}
Exemplo n.º 19
0
// TestCall_Something_Double
func TestCall_Something_Double(t *testing.T) {
	_m := maybe.New(3)
	m := maybe.Call(double, _m)
	assertSomethingValue(t, m, 6)
}
Exemplo n.º 20
0
// TestMap_Something_Err_Nil
func TestMap_Something_Err_Nil(t *testing.T) {
	_m := maybe.New(SOMETHING)
	m := _m.Map(MapErr_Nil)
	assertSomething(t, m)
}
Exemplo n.º 21
0
// TestCall_Multi_Something_Add
func TestCall_Multi_Something_Add(t *testing.T) {
	arg1 := maybe.New(1)
	arg2 := maybe.New(2)
	m := maybe.Call(add, arg1, arg2)
	assertSomethingValue(t, m, 3)
}
Exemplo n.º 22
0
// TestMap_Multi_Something_Ok_True_True
func TestMap_Multi_Something_Ok_True_True(t *testing.T) {
	_m := maybe.New(SOMETHING)
	m := _m.Map(MapOk_True).Map(MapOk_True)
	assertSomething(t, m)
}
Exemplo n.º 23
0
// TestCall_Multi_Mixed_Add
func TestCall_Multi_Mixed_Add(t *testing.T) {
	arg1 := maybe.New(1)
	m := maybe.Call(add, arg1, 2)
	assertSomethingValue(t, m, 3)
}
Exemplo n.º 24
0
// TestFilter_Something_False
func TestFilter_Something_False(t *testing.T) {
	_m := maybe.New(SOMETHING)
	m := _m.Filter(FilterFalse)
	assertNothing(t, m)
}
Exemplo n.º 25
0
// TestComposeMap_Increment_Something
func TestComposeMap_Increment_Something(t *testing.T) {
	f := maybe.ComposeMap(increment)
	_m := maybe.New(1)
	m := f(_m)
	assertSomethingValue(t, m, 2)
}
Exemplo n.º 26
0
// TestFilter_Something_Any_Panic
func TestFilter_Something_Any_Panic(t *testing.T) {
	m := maybe.New(SOMETHING)
	f := func() { m.Filter(FilterAny_Panic) }
	assertPanic(t, f, FILTER_PANIC)
}
Exemplo n.º 27
0
// TestComposeMap_Increment_Echo_Square_Something
func TestComposeMap_Increment_Echo_Square_Something(t *testing.T) {
	f := maybe.ComposeMap(square, MapEcho, increment)
	_m := maybe.New(3)
	m := f(_m)
	assertSomethingValue(t, m, 16)
}
Exemplo n.º 28
0
// TestFilter_Something_Any_True
func TestFilter_Something_Any_True(t *testing.T) {
	_m := maybe.New(SOMETHING)
	m := _m.Filter(FilterAny_True)
	assertSomething(t, m)
}
Exemplo n.º 29
0
// TestComposeFilter_True_FalseAny_Something
func TestComposeFilter_True_FalseAny_Something(t *testing.T) {
	f := maybe.ComposeFilter(FilterTrue, FilterAny_False)
	m := maybe.New(SOMETHING)
	b := f(m)
	assertFalse(t, b)
}
Exemplo n.º 30
0
// TestGetOrNil_Something
func TestGetOrNil_Something(t *testing.T) {
	m := maybe.New(SOMETHING)
	assertGetOrNil(t, m, SOMETHING)
}