1//go:build race
2// +build race
3
4package goja
5
6import (
7	"testing"
8)
9
10const (
11	tc39MaxTestGroupSize = 8000 // to prevent race detector complaining about too many goroutines
12)
13
14func (ctx *tc39TestCtx) runTest(name string, f func(t *testing.T)) {
15	ctx.testQueue = append(ctx.testQueue, tc39Test{name: name, f: f})
16	if len(ctx.testQueue) >= tc39MaxTestGroupSize {
17		ctx.flush()
18	}
19}
20
21func (ctx *tc39TestCtx) flush() {
22	ctx.t.Run("tc39", func(t *testing.T) {
23		for _, tc := range ctx.testQueue {
24			tc := tc
25			t.Run(tc.name, func(t *testing.T) {
26				t.Parallel()
27				tc.f(t)
28			})
29		}
30	})
31	ctx.testQueue = ctx.testQueue[:0]
32}
33