How to test @inbounds / @boundscheck behavior?

My understanding is that ]test will test a module with check-bounds=yes.

However, one of the things I’d like to test is that when a user uses @inbounds, the function I create is no longer elided, in other words the section marked by @boundscheck is properly ignored. But, with check-bounds=yes, I can’t. The julia base tests don’t really get around this, they simply check the bounds check options via Base.JLOptions().check_bounds and run the appropriate tests (ref. https://github.com/JuliaLang/julia/blob/c44644442949238da70670b547312ca1ae9a9c7d/test/boundscheck_exec.jl)

Is there any way I can do this?

You can run the test manually (i.e. julia tests/runtest.jl) and you can launch your own sub process with a different option. I’m pretty sure it was there (and probably still is) for the base bounds check test. The file you linked should have been the file run by the subprocess.

Edit: yes, ref https://github.com/JuliaLang/julia/blob/c44644442949238da70670b547312ca1ae9a9c7d/test/boundscheck.jl

3 Likes