blob: 14c82ef31e1dcc70dccc51ca7960486994cdd488 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
package repl
import (
"sync"
"testing"
)
func TestConcurrentExecutor(t *testing.T) {
// Test concurrent calls to executor()
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Add(1)
go func(id int) {
defer wg.Done()
executor("20% of 150")
}(i)
}
wg.Wait()
}
func TestConcurrentRPN(t *testing.T) {
// Test concurrent calls to runRPN()
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Add(1)
go func(id int) {
defer wg.Done()
runRPN("3 4 +")
}(i)
}
wg.Wait()
}
func TestConcurrentRatModeToggle(t *testing.T) {
// Test concurrent calls to executor() that change mode
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Add(1)
go func(id int) {
defer wg.Done()
executor("rat toggle")
}(i)
}
wg.Wait()
}
func TestConcurrentExecutorAndRPN(t *testing.T) {
// Test concurrent calls to executor() and runRPN()
var wg sync.WaitGroup
for i := 0; i < 5; i++ {
wg.Add(2)
go func(id int) {
defer wg.Done()
executor("20% of 150")
}(i)
go func(id int) {
defer wg.Done()
runRPN("3 4 +")
}(i)
}
wg.Wait()
}
|