mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 11:37:46 +00:00
runtime: handle negative sleep times
This change fixes the edge case where a negative sleep time is provided. When this happens, the call now returns immediately (as specified by the docs for time.Sleep).
This commit is contained in:
Vendored
+5
@@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -29,6 +30,10 @@ func main() {
|
||||
fmt.Println("strings.IndexByte:", strings.IndexByte("asdf", 'd'))
|
||||
fmt.Println("strings.Replace:", strings.Replace("An example string", " ", "-", -1))
|
||||
|
||||
// package time
|
||||
time.Sleep(time.Millisecond)
|
||||
time.Sleep(-1) // negative sleep should return immediately
|
||||
|
||||
// Exit the program normally.
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user