<commit_before>import threading/Thread

for (i in 0 .. 10) {
	m := Mutex new()
	m lock()
	m unlock()
	m destroy()
}<commit_msg>Improved test for Mutex<commit_after>use ooc-unit
import threading/Thread

MutexTest: class extends Fixture {
	init: func {
		super("Mutex")
		this add("basic", This _testBasicUsage)
	}
	_testBasicUsage: static func {
		threadCount := 4
		countPerThread := 1_000
		mutex := Mutex new()
		value := Cell<Int> new(0)
		threads := Thread[threadCount] new()
		job := func {
			for (i in 0 .. countPerThread) {
				mutex lock()
				value set(value get() + 1)
				mutex unlock()
				Thread yield()
			}
		}
		for (i in 0 .. threads length) {
			threads[i] = Thread new(|| job())
			expect(threads[i] start())
		}
		for (i in 0 .. threads length) {
			expect(threads[i] wait())
			threads[i] free()
		}
		threads free()
		mutex destroy()
		expect(value get() == countPerThread * threadCount)
	}
}

MutexTest new() run()
{'fraction_non_alphanumeric': 0.14498933901918976, 'fraction_numerical': 0.013859275053304905, 'mean_word_length': 3.3073394495412844, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '7622931', 'n_tokens_mistral': 380, 'n_tokens_neox': 329, 'n_words': 100}