From 8d82a394042feb858f8b8b40f199f9ede5cc1b83 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sat, 4 Sep 2021 21:09:25 +1000 Subject: Make Operation generic From https://github.com/anacrolix/stm/commit/80e033aa1f2218b83fb5891671ed795de72e19d5 --- stm_test.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'stm_test.go') diff --git a/stm_test.go b/stm_test.go index fdf7af2..4103563 100644 --- a/stm_test.go +++ b/stm_test.go @@ -125,7 +125,7 @@ func TestVerify(t *testing.T) { func TestSelect(t *testing.T) { // empty Select should panic - require.Panics(t, func() { Atomically(Select()) }) + require.Panics(t, func() { Atomically(Select[struct{}]()) }) // with one arg, Select adds no effect x := NewVar[int](2) @@ -135,15 +135,16 @@ func TestSelect(t *testing.T) { picked := Atomically(Select( // always blocks; should never be selected - VoidOperation(func(tx *Tx) { + func(tx *Tx)int { tx.Retry() - }), + panic("unreachable") + }, // always succeeds; should always be selected - func(tx *Tx) interface{} { + func(tx *Tx) int { return 2 }, // always succeeds; should never be selected - func(tx *Tx) interface{} { + func(tx *Tx) int { return 3 }, )) @@ -152,9 +153,9 @@ func TestSelect(t *testing.T) { func TestCompose(t *testing.T) { nums := make([]int, 100) - fns := make([]Operation, 100) + fns := make([]Operation[struct{}], 100) for i := range fns { - fns[i] = func(x int) Operation { + fns[i] = func(x int) Operation[struct{}] { return VoidOperation(func(*Tx) { nums[x] = x }) }(i) // capture loop var } -- cgit v1.2.3