ocaml
Version:
OCaml Compiler as an esy npm Package
27 lines (22 loc) • 1.3 kB
Plain Text
This directory contains tests to check that OCaml values are correctly
passed between OCaml and C when a primitive takes some or all of its
arguments unboxed/untagged and/or return its result unboxed/untagged.
To test one primitive we do:
- write all its argument and expected result in buffer A
- call the C external using arguments read from buffer A
- the C function write all the arguments it receive into buffer B
- the C function read the result from buffer A and returns it
- on the OCaml side we write the received result into buffer B
- the test is successful if A and B have the same contents
Between each call, we call a function with 128 value arguments set to
0 and a function with 32 unboxed float arguments set to 0., just to
clean-up the registers and stacks in case garbage would make a test
succeed. We don't pass more floats as it doesn't build on arm32.
We construct the set of primitives to test as follow:
- all combination of unboxed int32/int64/float arguments for functions
taking up to 6 arguments (with more than 6 ocamlopt takes a really
long time to compile the test files)
- a bunch of manual tests for the rest and specific patterns.
The list is [Gen_test.manual_tests]
We test the set of primitives a thousand times, with different random
data each time.