Tests
pixi run test # CPU tests
pixi run test-gpu # on a host with a supported GPUSuite
- The specification vectors in
tests/vectors_data.mojo, generated from the spec'svectors.json. - Long fills, scalar draws and random access against the dumps in
tests/data, copied fromtandem-c/tests/data. - Fills against the scalar draws at offsets and lengths that cut rows and chunks.
- The conformance files of the spec: bounded integers, normals, exponentials and weighted choice, with the stream and dump hashes.
- GPU fills against the CPU fills.
Files
tests/test_vectors.mojochecks every vector of the specification.tests/vectors_data.mojois generated from the spec repository'svectors.jsonbytools/gen_vectors.py.tests/test_dumps.mojocompares long fills, scalar draws and random access with the reference stream dumps intests/data, complex fills included. The dumps are copies oftandem-c/tests/data.tests/test_tandem.mojocovers scalar draws of every width, alignment, random access,set_position, chunk lengths, split, sub and fork.tests/test_fills.mojocompares every fill with the scalar draws of its type, at chunk lengths, offsets and lengths that cut rows and chunks, and checks the position afterwards.tests/test_conformance.mojoreads the byte copies of the spec'sconformance/*.jsonintests/conformancethroughtests/conformance.mojo, and demonstrates every item of the spec'sconformance/CHECKLIST.mdat 2a4bd08. Every case of the bounded, normal, exponential and weighted choice files runs as a fill, as scalar draws and cut at elements 1, 7, 20, 21 and n - 1 (Float32normals at 2, 8, 20 and the largest even element below n), bit for bit with the end position, including thef32normals. It builds the choice tables and comparesS,cutandalias, and checks the stream and dump hashes ofhashes.jsonby SHA-256 and FNV-1a from the key. It checks the global draw index of the fallback, the width of the bounded draws, empty fills, the pair rule and oddnof thef32normals, rejected choice weights and the choice law, random access, a complex draw across a block, and the position bounds.tests/test_derived.mojochecks the bounded fills against their definition at every length that cuts a SIMD block, longf64normal, bounded and exponential fills cut into chunks, thef32normals against the exact formula, the logarithm and thef32series against libm, and the moments of the normals and the moments and KS distance of 1e7 exponentials.tests/test_gpu.mojocompares the GPU fills with the CPU fills over chunk lengths and row ranges, and with the dump.
Fixtures
tests/vectors_data.mojo is generated from the spec
repository's vectors.json by
tools/gen_vectors.py. The dumps in tests/data
are copies of tandem-c/tests/data.
tests/conformance/*.json are byte copies of tandem-spec
2a4bd08 conformance/*.json.
tools/gen_zig_tables.py writes zig_tables.mojo
from the spec's tables/normal_f64_zig1024.json. CI checks
all of them. mojo run -I . tools/dump_normals.mojo out.bin
writes the bytes of tandem-c's
tools/dump_normals.c, SHA-256
700ec4d2f4d6b82aaa56c6eff18a4e5919585fdbd093988773383d580ea610d1.
CI
- CI runs
pixi run teston Ubuntu. CI does not run the GPU tests. - One job checks that the vector data is current, and one that the dumps and the conformance files are.