Skip to content

Commit

Permalink
Merge pull request #168 from corywalker/corywalker
Browse files Browse the repository at this point in the history
Add tests for concurrent evaluation on the same EvalState.
  • Loading branch information
corywalker committed Oct 10, 2018
2 parents 76de0a3 + ae04b4e commit 6d7cc29
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions expreduce/cas_test.go
Expand Up @@ -231,6 +231,7 @@ func TestConcurrency(t *testing.T) {

var wg sync.WaitGroup

// Test concurrent evals on different EvalStates.
for i := 0; i < 10; i++ {
wg.Add(1)
go func (t *testing.T) {
Expand All @@ -240,4 +241,24 @@ func TestConcurrency(t *testing.T) {
}(t)
}
wg.Wait()

// Test read-only concurrent evals on the same EvalState.
for i := 0; i < 100; i++ {
wg.Add(1)
go func (t *testing.T, es *EvalState) {
defer wg.Done()
CasAssertSame(t, es, "2x", "D[x^2, x]")
}(t, es1)
}
wg.Wait()

// Test writing concurrent evals on the same EvalState.
for i := 0; i < 1000; i++ {
wg.Add(1)
go func (t *testing.T, i int, es *EvalState) {
defer wg.Done()
EvalInterp(fmt.Sprintf("testVar := %v", i), es)
}(t, i, es1)
}
wg.Wait()
}

0 comments on commit 6d7cc29

Please sign in to comment.