mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-14 01:34:35 +00:00
#+build !netbsd
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#+build !netbsd
|
||||
package test_core_math_rand
|
||||
|
||||
import "core:math"
|
||||
@@ -11,7 +12,9 @@ Generator :: struct {
|
||||
}
|
||||
|
||||
// Disable on NetBSD due to Illegal Instruction on CI, even with `microarch:native`
|
||||
@(test, disabled=ODIN_OS == .NetBSD)
|
||||
// `@(test, disable="...")` still runs the test.
|
||||
|
||||
@(test)
|
||||
test_prngs :: proc(t: ^testing.T) {
|
||||
gens := []Generator {
|
||||
{
|
||||
@@ -49,8 +52,7 @@ rand_determinism :: proc(t: ^testing.T, rng: Generator) {
|
||||
testing.expectf(t, first_value == second_value, "rng '%s' is non-deterministic.", rng.name)
|
||||
}
|
||||
|
||||
// Disable on NetBSD due to Illegal Instruction on CI, even with `microarch:native`
|
||||
@(test, disabled=ODIN_OS == .NetBSD)
|
||||
@(test)
|
||||
test_default_rand_determinism_user_set :: proc(t: ^testing.T) {
|
||||
rng_state_1 := rand.create(13)
|
||||
rng_state_2 := rand.create(13)
|
||||
|
||||
62
tests/core/slice/not_netbsd.odin
Normal file
62
tests/core/slice/not_netbsd.odin
Normal file
@@ -0,0 +1,62 @@
|
||||
#+build !netbsd
|
||||
package test_core_slice
|
||||
|
||||
import "core:slice"
|
||||
import "core:testing"
|
||||
import "core:math/rand"
|
||||
|
||||
// Disable on NetBSD due to Illegal Instruction on CI, even with `microarch:native`
|
||||
// `@(test, disable="...")` still runs the test.
|
||||
|
||||
@(test)
|
||||
test_unique :: proc(t: ^testing.T) {
|
||||
for v in UNIQUE_TEST_VECTORS {
|
||||
assorted := v[0]
|
||||
expected := v[1]
|
||||
|
||||
uniq := slice.unique(assorted)
|
||||
testing.expectf(t, slice.equal(uniq, expected), "Expected slice.uniq(%v) == %v, got %v", v[0], v[1], uniq)
|
||||
}
|
||||
|
||||
for v in UNIQUE_TEST_VECTORS {
|
||||
assorted := v[0]
|
||||
expected := v[1]
|
||||
|
||||
uniq := slice.unique_proc(assorted, proc(a, b: int) -> bool {
|
||||
return a == b
|
||||
})
|
||||
testing.expectf(t, slice.equal(uniq, expected), "Expected slice.unique_proc(%v, ...) == %v, got %v", v[0], v[1], uniq)
|
||||
}
|
||||
|
||||
r := rand.create(t.seed)
|
||||
context.random_generator = rand.default_random_generator(&r)
|
||||
|
||||
// 10_000 random tests
|
||||
for _ in 0..<10_000 {
|
||||
assorted: [dynamic]i64
|
||||
expected: [dynamic]i64
|
||||
|
||||
// Prime with 1 value
|
||||
old := rand.int63()
|
||||
append(&assorted, old)
|
||||
append(&expected, old)
|
||||
|
||||
// Add 99 additional random values
|
||||
for _ in 1..<100 {
|
||||
new := rand.int63()
|
||||
append(&assorted, new)
|
||||
if old != new {
|
||||
append(&expected, new)
|
||||
}
|
||||
old = new
|
||||
}
|
||||
|
||||
original := slice.clone(assorted[:])
|
||||
uniq := slice.unique(assorted[:])
|
||||
testing.expectf(t, slice.equal(uniq, expected[:]), "Expected slice.uniq(%v) == %v, got %v", original, expected, uniq)
|
||||
|
||||
delete(assorted)
|
||||
delete(original)
|
||||
delete(expected)
|
||||
}
|
||||
}
|
||||
@@ -225,60 +225,6 @@ UNIQUE_TEST_VECTORS :: [][2][]int{
|
||||
{{1,2,4,4,5}, {1,2,4,5}},
|
||||
}
|
||||
|
||||
// Disable on NetBSD due to Illegal Instruction on CI, even with `microarch:native`
|
||||
@(test, disabled=ODIN_OS == .NetBSD)
|
||||
test_unique :: proc(t: ^testing.T) {
|
||||
for v in UNIQUE_TEST_VECTORS {
|
||||
assorted := v[0]
|
||||
expected := v[1]
|
||||
|
||||
uniq := slice.unique(assorted)
|
||||
testing.expectf(t, slice.equal(uniq, expected), "Expected slice.uniq(%v) == %v, got %v", v[0], v[1], uniq)
|
||||
}
|
||||
|
||||
for v in UNIQUE_TEST_VECTORS {
|
||||
assorted := v[0]
|
||||
expected := v[1]
|
||||
|
||||
uniq := slice.unique_proc(assorted, proc(a, b: int) -> bool {
|
||||
return a == b
|
||||
})
|
||||
testing.expectf(t, slice.equal(uniq, expected), "Expected slice.unique_proc(%v, ...) == %v, got %v", v[0], v[1], uniq)
|
||||
}
|
||||
|
||||
r := rand.create(t.seed)
|
||||
context.random_generator = rand.default_random_generator(&r)
|
||||
|
||||
// 10_000 random tests
|
||||
for _ in 0..<10_000 {
|
||||
assorted: [dynamic]i64
|
||||
expected: [dynamic]i64
|
||||
|
||||
// Prime with 1 value
|
||||
old := rand.int63()
|
||||
append(&assorted, old)
|
||||
append(&expected, old)
|
||||
|
||||
// Add 99 additional random values
|
||||
for _ in 1..<100 {
|
||||
new := rand.int63()
|
||||
append(&assorted, new)
|
||||
if old != new {
|
||||
append(&expected, new)
|
||||
}
|
||||
old = new
|
||||
}
|
||||
|
||||
original := slice.clone(assorted[:])
|
||||
uniq := slice.unique(assorted[:])
|
||||
testing.expectf(t, slice.equal(uniq, expected[:]), "Expected slice.uniq(%v) == %v, got %v", original, expected, uniq)
|
||||
|
||||
delete(assorted)
|
||||
delete(original)
|
||||
delete(expected)
|
||||
}
|
||||
}
|
||||
|
||||
@test
|
||||
test_compare_empty :: proc(t: ^testing.T) {
|
||||
a := []int{}
|
||||
|
||||
Reference in New Issue
Block a user