Adds support for writing primitives, including tests.