From 413ab2390499d5b30253b314d3afde49112e4ae6 Mon Sep 17 00:00:00 2001 From: ajet Date: Tue, 4 Nov 2025 14:58:08 -1000 Subject: [PATCH] add PBT for list len --- list/list_test.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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") }, }) })