Skip to content

Commit

Permalink
♻️ Added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mymmrac committed Jun 19, 2023
1 parent 9cab5ba commit 0225603
Show file tree
Hide file tree
Showing 4 changed files with 420 additions and 29 deletions.
14 changes: 14 additions & 0 deletions internal/test/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ func Equal[T comparable](t *testing.T, actual, expected T) {
}
}

func EqualEl[T comparable, S []T](t *testing.T, actual, expected S) {
t.Helper()

if len(actual) != len(expected) {
t.Fatalf("%+v is not equal to %+v", actual, expected)
}

for i := 0; i < len(actual); i++ {
if actual[i] != expected[i] {
t.Fatalf("%+v is not equal to %+v", actual, expected)
}
}
}

func True(t *testing.T, actual bool) {
t.Helper()

Expand Down
6 changes: 6 additions & 0 deletions internal/testdata/main4.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ func main() {
fmt.Println("Before")
})

r.WaitFor(time.Millisecond)

r.Do(func() {
doStuff(r)
})

r.WaitFor(time.Millisecond)

r.Do(func() {
fmt.Println("After")
})

r.WaitFor(time.Millisecond)

r.Do(func() {
doStuff(r)
})
Expand Down
20 changes: 8 additions & 12 deletions internal/testdata/main9.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,21 @@ func main() {
fmt.Println("=")
})
r.WaitFor(t)
r.Func(func() {
r.Repeat(n, func() {
r.Do(func() {
fmt.Println("+")
})
r.WaitFor(t)
r.Repeat(n, func() {
r.Do(func() {
fmt.Println("+")
})
r.WaitFor(t)
})
r.WaitFor(t)
r.Do(func() {
fmt.Println("=")
})
r.Func(func() {
r.Repeat(n, func() {
r.Do(func() {
fmt.Println("-")
})
r.WaitFor(t)
r.Repeat(n, func() {
r.Do(func() {
fmt.Println("-")
})
r.WaitFor(t)
})
r.WaitFor(t)
r.Do(func() {
Expand Down
Loading

0 comments on commit 0225603

Please sign in to comment.