diff --git a/list/list_test.go b/list/list_test.go index 55e3cfd..61aa514 100644 --- a/list/list_test.go +++ b/list/list_test.go @@ -40,19 +40,24 @@ func TestListRest(t *testing.T) { assert.Equal(t, Empty(), Rest(Empty().Rest()), "should return rest sublist") } -type listGen struct{} - // generative tests -func TestConjIncreasesLen(t *testing.T) { - l := Empty() +func ListLengthProperty(t *testing.T) { + myList := Empty() expectedSized := 0 rapid.Check(t, func(t *rapid.T) { t.Repeat(map[string]func(*rapid.T){ "conj": func(t *rapid.T) { - expectedSized += 0 + expectedSized += 1 + myList = myList.Conj(rapid.Int().Draw(t, "el")) + }, + "rest": func(t *rapid.T) { + if !myList.IsEmpty() { + expectedSized -= 1 + } + myList = myList.Rest() }, "": func(t *rapid.T) { - assert.Equal(t, l.Len(), expectedSized, "must be equal") + assert.Equal(t, myList.Len(), expectedSized, "must be equal") }, }) })