You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
329 B

  1. package readline
  2. import (
  3. "testing"
  4. "time"
  5. )
  6. func TestRace(t *testing.T) {
  7. rl, err := NewEx(&Config{})
  8. if err != nil {
  9. t.Fatal(err)
  10. return
  11. }
  12. go func() {
  13. for range time.Tick(time.Millisecond) {
  14. rl.SetPrompt("hello")
  15. }
  16. }()
  17. go func() {
  18. time.Sleep(100 * time.Millisecond)
  19. rl.Close()
  20. }()
  21. rl.Readline()
  22. }