Per the leading zero in its version number1 rejig is presently considered “beta” software, yet it is well-tested. This document describes the methods regularly employed during development and prerelease qualification to ensure it continues approaching an indefinite future ideal of rock-solid stability.
Unit Tests
rejig makes good use of Go’s built-in first-class testing and code coverage features. The majority of the code in rejig gets tested this way, helping to ensure that released features do not accidentally regress.
Purposeful breakages do continue occurring, for better or worse. Thus “beta.”
While there are a fair number of tests in the suite to verify that known-bad inputs are caught, there is precious little verification that the resulting error messages are stable from one release to the next. Our focus is on ensuring that known-good inputs continue to parse as they historically have. For the rest, it suffices that bad inputs halt processing; details beyond that are subject to change.
Integration Tests
text "golden" small "test" small "source" small
LEG1: arrow go 1 heading 30 "up to UTF-8" small aligned above
LEG2: arrow from LEG1.end go 1 heading 150 "down to P47" small aligned above
BASE: arrow ↔ from LEG1.start to LEG2.end \
"round-trip" small aligned above \
"bidi check" small aligned below
circle invisible radius .1 with .s at LEG1.end
spline → \
from previous.s \
to previous.sw \
to previous.w \
to previous.nw \
to previous.n \
to previous.ne \
to previous.e \
to previous.se \
to previous.s
text "text-to-text" small "sanity check" small with .s at previous.n
circle invisible radius .1 with .w at LEG2.end
spline → \
from previous.w \
to previous.nw \
to previous.n \
to previous.ne \
to previous.e \
to previous.se \
to previous.s \
to previous.sw \
to previous.w
text "P47-to-P47" small "sanity check" small with .n at previous.s
line from LEG1.start to LEG1.end to LEG2.end close fill lightblue behind LEG1
dot at LEG1.start color gold radius .05 behind previous
→ /pikchrshowThere are many RPN test programs included in the rejig source tree, plus a round-tripping script that performs several transformations depicted here. In prose:
- “golden” test program to the canonical R47-inspired UTF-8 form
- UTF-8 to UTF-8 to verify canonicalization
- UTF-8 down to the P47 byte-coded form
- P47 to P47 to verify byte-code round-tripping
- golden test form straight to P47, bypassing the UTF-8 intermediary to ensure it doesn’t hide conversion errors
- reverse of same to ensure we get back to the original
Although this may seem exceedingly complicated, every one of those steps has proven valuable at least once. If we do not cover all likely conversion paths in our automated testing, we can be sure our users will do it for us. 🫢
Even then, we do not attempt all possible endpoint combinations, not in pairs, and certainly not in arbitrary chains like RePIG to HP-15C to…oh, I dunno, HP-42S? Our intent is that once we get the translation to and from the canonical form right, everything else will flow from that, within reason.
Machine-specific dialect differences are pinned in place with appropriate --validate and --syntax flags.
Non-coding comments (@) are allowed as test annotations. The fact that they are stripped from P47 and HP raw outputs is not flagged as a test failure.
Failures in the chain indicate a problem with the software, as do differences in the output relative to prior runs.
These test files do change from time to time, but always to track known changes in rejig behavior. We do not hack the test data merely to placate the tests.
The most important of these are the AllOps tests, encoding the range of supported operations for each family rejig understands. It’s not a 1:1 relationship; these AllOps files leave out device features rejig does not support. Conversely, one of the ways we test new rejig features is by extending the AllOps test for that machine type. For the HP-42S family the amalgam is split into non-overlapping layer deltas: tests/hp41c/AllOps (shared forty / HP-41C base), tests/dm41x/AllOps (DM41X patched-mainframe XROMs only), tests/hp42s/AllOps (original HP-42S additions only), tests/free42/AllOps (Free42 additions only), and tests/plus42/AllOps (Plus42-only encodings such as XSTR).
Beyond the AllOps inventory, each suite keeps a number of secondary fixtures: focused program fragments that fill gaps between the single-op inventory and broader conversion paths. Early development also leaned on large site-demo programs; those stay on Enter RPN and are not re-vendored into tests/. As each idea lands as a first-class feature, redundant full-program coverage is trimmed in favor of the focused fixtures already in-tree.
That is not to say that make test skips realistic programs — roundtrip and lowering still exercise committed fixtures end-to-end. Local uncommitted extras may accumulate in a private checkout, but they are not part of the shared suite.
Some of this feeds back into the code-coverage testing via “make intcov”, backstopping the regular unit testing. If our test programs cannot trigger a goodly portion of the code, we may consider that cause to expand the test program to address that lack.
Property-Based Testing
PBT is a strategy for stochastically asserting “properties” of a system. It is best used when complete coverage over a range is too expensive, even impossible.
For example, a calculator’s ➕ button should always obey the mathematical properties for addition over the numeric types the machine understands. The problem PBT addresses is that actually testing all possible inputs would take approximately forever, for although the number is necessarily finite in any physical calculator that lacks a CAS, the number of discrete states is large enough that even checking billions per second isn’t fast enough to get through the complete range in a reasonable amount of time.
Thankfully, it suffices to augment the standard edge-case testing with, say, 100 random operands and check that they all obey the known properties of addition. The chances then of missing something become sufficiently small that we can confidently make assertions like, “The properties of addition remain satisfied in this version of the software.”
While you might think rejig could benefit greatly from this strategy — being calculator-adjacent — it is not a calculator itself. What rejig knows and cares about are the byte-coded representation of the addition operation on several calculator designs, not the mathematical properties of addition implemented by those machines.
In a lot of cases, we can afford to test every possible input. For instance, there are presently ~1500 ops defined for our primary R47 program representation, which is a lot, but well within the capacity of a computer to validate with regular unit tests. In this way, we check that no duplicate op names ever get accidentally added, creating an unwanted ambiguity.
Nevertheless, rejig uses the Rapid library for PBT where it makes sense. One good example is when checking that our integration with the decimal floating point libraries are working properly. In addition to the small number of canned values we have it to check to establish key boundary lines, we then fire off a number of random PBT checks to cover enough range that we can be confident we didn’t mess something up.
Lowering Tests
The lowering script tries to convert every tests/r47/*.p47 file to each of the other machine families we support. In this way, we try to keep the conversion capacity as broad as possible, even when it means adding methods to allow rejig to emulate the capabilities of more powerful machines in terms of those available on the lesser ones.
The prime example of this is that we emulate DROP𝑥 on all machines that lack this op, which is all but the forty-series ones.2
Test-First Design
Several intentional CLI defaults make all this simpler: --line-numbers being optional, the limited nature of the metadata emitted in HP-15C output, fixed formatting over locale-based formatting, and so forth.
We recognize anything that would cause undue test churn detrimental to our motivation to run the tests frequently, thus bad for reliability.
(You may now wish to return to the rejig home page.)
License
This work is © 2026 by Warren Young and is licensed under CC BY-NC-SA 4.0