| 1 | import math { sqrt } |
| 2 | import time |
| 3 | |
| 4 | fn get_hypot(a f64, b f64) f64 { |
| 5 | time.sleep(100 * time.millisecond) |
| 6 | c := sqrt(a * a + b * b) |
| 7 | return c |
| 8 | } |
| 9 | |
| 10 | fn test_main() { |
| 11 | mut arr := &[]thread f64{} |
| 12 | for num in 1 .. 1000 { |
| 13 | g := go get_hypot(num, num) |
| 14 | arr << g |
| 15 | } |
| 16 | result := arr.wait() |
| 17 | assert result[0] == 1.4142135623730951 |
| 18 | } |
| 19 |