<commit_before>package pow

import (
	"fmt"
	"math/big"
	"sync"
	"testing"

	"github.com/ericlagergren/decimal/internal/c"
)

func TestBigTen(t *testing.T) {
	errc := make(chan error)

	var wg sync.WaitGroup
	for i := uint64(0); i < BigTabLen+10; i++ {
		wg.Add(1)
		go func(i uint64) {
			comp := BigTen(i)
			n := new(big.Int).SetUint64(i)
			act := n.Exp(c.TenInt, n, nil)
			if act.Cmp(comp) != 0 {
				cs, as := comp.String(), act.String()
				errc <- fmt.Errorf(`%d:
got   : (%d) %s
wanted: (%d) %s
`, i, len(cs), cs, len(as), as)
			}
			wg.Done()
		}(i)
	}

	donec := make(chan struct{})
	go func() {
		wg.Wait()
		donec <- struct{}{}
	}()

	for {
		select {
		case err := <-errc:
			t.Fatal(err.Error())
		case <-donec:
			return
		}
	}
}
<commit_msg>internal/arith/pow: limit number of workers to 1000 so we don't hit race's limit of 8192 goroutines<commit_after>package pow

import (
	"fmt"
	"math/big"
	"sync"
	"testing"

	"github.com/ericlagergren/decimal/internal/c"
)

func TestBigTen(t *testing.T) {
	errc := make(chan error)
	workc := make(chan struct{}, 1000)
	for i := 0; i < 1000; i++ {
		workc <- struct{}{}
	}

	var wg sync.WaitGroup
	for i := uint64(0); i < BigTabLen+10; i++ {
		<-workc
		wg.Add(1)
		go func(i uint64) {
			comp := BigTen(i)
			n := new(big.Int).SetUint64(i)
			act := n.Exp(c.TenInt, n, nil)
			if act.Cmp(comp) != 0 {
				cs, as := comp.String(), act.String()
				errc <- fmt.Errorf(`%d:
got   : (%d) %s
wanted: (%d) %s
`, i, len(cs), cs, len(as), as)
			}
			wg.Done()
			workc <- struct{}{}
		}(i)
	}

	donec := make(chan struct{})
	go func() {
		wg.Wait()
		donec <- struct{}{}
	}()

	for {
		select {
		case err := <-errc:
			t.Fatal(err.Error())
		case <-donec:
			return
		}
	}
}

{'fraction_non_alphanumeric': 0.205320994794679, 'fraction_numerical': 0.022556390977443608, 'mean_word_length': 2.8189845474613686, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5604680', 'n_tokens_mistral': 880, 'n_tokens_neox': 756, 'n_words': 178}