2016-09-15 13:11:25 +03:00
|
|
|
package readline
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestRace(t *testing.T) {
|
2018-10-13 20:32:46 +03:00
|
|
|
rl, err := NewEx(&Config{
|
|
|
|
Prompt: StaticPrompt(""),
|
|
|
|
})
|
2016-09-15 13:11:25 +03:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
for range time.Tick(time.Millisecond) {
|
2018-10-13 20:32:46 +03:00
|
|
|
rl.SetPrompt(StaticPrompt("hello"))
|
2016-09-15 13:11:25 +03:00
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
rl.Close()
|
|
|
|
}()
|
|
|
|
|
|
|
|
rl.Readline()
|
|
|
|
}
|