OJaml / docsProject documentation

Reference

Validation Strategy

Look up syntax, contracts, layouts, algorithms, and exact behavior.

OJaml is validated with a Node test suite that exercises parsing, emitted WebAssembly text, runtime execution, diagnostics, polymorphic functions with int/float specialization, built-in and user-defined module opens, module type declarations, abstract signature type entries, concrete record and variant signature manifests, val signature ascription, opened module-local types and constructors, nested modules, module-local record and algebraic data types, ambiguous-name rejection, expression sequencing and unit-left diagnostics, forward pipelines through direct functions, stdlib functions, returned closures, and specialization, exact editor-example output transcripts, power precedence and associativity, runtime access traps, tuple and record type checking, record and algebraic data type declarations with type parameters, value annotations, function parameter annotations, higher-order function annotations, tuple projection, pair helpers, tuple, record, list, array, set, map, and constructor pattern matching, tuple and record formatting, polymorphic arrays, polymorphic lists, polymorphic sets, polymorphic maps, polymorphic ADT constructor instantiation, pattern matching, top-level and local recursion, first-class high-arity functions, staged closures, collection append/reverse/filter/exists/for_all/map/iter/fold behavior, to_string formatting, print/println behavior, and editor hover metadata.

let main =
  let m = Map.set (Map.empty ()) "one" 1 in
  let m = Map.set m "two" "nope" in
  Map.get m "one"
Map type regression test. This must fail because the second Map.set attempts to write a string value into a (string, int) map.
check⁡(P)=ok∧emit⁡(P)=W⇒instantiate⁡(W)  exports  main\operatorname{check}(P)=ok \land \operatorname{emit}(P)=W \Rightarrow \operatorname{instantiate}(W)\;\text{exports}\;main
Round-trip execution obligation. For valid programs, emitted WebAssembly should produce an instantiable module with main.

The strongest tests are negative tests for the checker and runtime integration tests for language features. Negative tests prove the checker rejects invalid programs before emission. Runtime tests prove accepted programs still execute correctly after lowering to WebAssembly.

invalid⁡(P)⇒markers⁡(P)≠∅\operatorname{invalid}(P) \Rightarrow \operatorname{markers}(P) \ne \varnothing
Negative diagnostic obligation. Programs with static errors should surface diagnostics in the editor.

The site build is also part of validation because OJaml is consumed as a submodule-backed editor package. A successful frontend build confirms the paper content, route import, and package integration still compile together.

  • Feature tests cover each supported syntax and standard-library family.
  • Compiler tests inspect generated WAT for scalar programs.
  • Runtime tests execute WASM and compare main result plus captured output transcripts.
  • Runtime safety tests assert traps for negative array lengths, out-of-bounds array access, empty-list head/tail, and missing map keys.
  • Collection tests cover append and reverse order, empty operands, singleton values, source preservation, predicate short-circuiting, polymorphic element values, and mismatch diagnostics for arrays and lists.
  • Specialization tests cover direct and higher-order polymorphic function calls across int and float call sites, including power-based helpers.
  • Module tests cover parsing, qualified member calls, user-defined opens, module type declarations, abstract type signatures, concrete record and variant signature manifests, polymorphic val signature ascription, opened module-local types and constructors, local shadowing, sibling references, closures that capture module sibling values, duplicate diagnostics, unknown opens, missing signature members, mismatched signature types, and nested-module behavior.
  • High-arity tests cover first-class function values, returned and staged closures, local recursive closures, mixed heap/immediate arguments, scratch-local growth past the old fixed pool, generated indirect-call types, and editor-example output.
  • Local recursion tests cover local function syntax, self-capture, captured outer locals, non-function rejection, editor examples, and hover strings.
  • Tuple tests cover parsing, indexed projection, fst/snd helpers, nested formatting, tuple pattern destructuring, collection nesting, structural type mismatches, direct-main rejection, editor examples, and hover strings.
  • Record tests cover parsing, field access, sorted-label formatting, collection nesting, record pattern destructuring, closure captures, missing-field diagnostics, duplicate-label diagnostics, direct-main rejection, editor examples, and hover strings.
  • Algebraic data type tests cover nullary and payload constructors, polymorphic option/result-style declarations, generic record aliases, constructor exhaustiveness, parameter arity diagnostics, mismatched payload diagnostics, editor examples, and hover strings.
  • Array pattern tests cover parsing, empty and fixed-length patterns, nested element patterns, closure-bound matches, type mismatches, conservative exhaustiveness, editor examples, and hover strings.
  • List pattern tests cover [], right-associative cons patterns, recursive destructuring, closure captures, conservative exhaustiveness, diagnostics, editor examples, and hover strings.
  • Set tests cover empty sets, persistence, duplicate suppression, float equality, nested formatting, membership diagnostics, and hover strings.
  • Editor tests assert diagnostics and hover strings for inferred local and stdlib types.