initial import
This commit is contained in:
37
core/threading/routines_test.go
Normal file
37
core/threading/routines_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package threading
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"testing"
|
||||
|
||||
"zero/core/lang"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestRoutineId(t *testing.T) {
|
||||
assert.True(t, RoutineId() > 0)
|
||||
}
|
||||
|
||||
func TestRunSafe(t *testing.T) {
|
||||
log.SetOutput(ioutil.Discard)
|
||||
|
||||
i := 0
|
||||
|
||||
defer func() {
|
||||
assert.Equal(t, 1, i)
|
||||
}()
|
||||
|
||||
ch := make(chan lang.PlaceholderType)
|
||||
go RunSafe(func() {
|
||||
defer func() {
|
||||
ch <- lang.Placeholder
|
||||
}()
|
||||
|
||||
panic("panic")
|
||||
})
|
||||
|
||||
<-ch
|
||||
i++
|
||||
}
|
||||
Reference in New Issue
Block a user