Class IsTestProgram

java.lang.Object
org.ek9lang.compiler.common.IsTestProgram
All Implemented Interfaces:
Predicate<ISymbol>

public final class IsTestProgram extends Object implements Predicate<ISymbol>
THE answer to "is this a @Test program?" (and, with its siblings, what execution group it is in) — use this, do not read the squirrelled key directly.

The encoding contract, in one place because it keeps needing restating

Phase 1 (DefinitionListener) records a @Test directive on the program aggregate as two deliberately separate squirrelled keys:

  • CommonValues.TEST_DIRECTIVE — its presence is the authoritative "this is a test". Its value is the sequential execution group ("" when ungrouped), which TestRunner schedules on.
  • CommonValues.REQUIREMENT_REF — the requirement the test anchors, on its own key. It is NOT packed into the group value, because a group name that happened to look like a requirement id would otherwise silently reschedule the test.
  • CommonValues.TEST_EXIT_CODE — the exit code the test declared with "EXIT:<n>", on its own key for the same reason; absent means 0.

Consolidated 2026-08-04: the presence check was inlined at seven sites across three modules (compiler-main's call-graph collector, the MCP anchor source / anchor tool / neighbourhood extractor, the CLI test runner, and two IDE providers), two of them private methods that had independently arrived at the same name. Nothing tied them together, so the contract above lived only in prose comments that each site restated slightly differently.

No statics (Steve, 2026-10-28; was TestPrograms): each question is a class to hold an instance of - this one, IsWithinTestProgram, TestExecutionGroupOf, DeclaredTestExitCodeOf and ExpectedTestExitCodeOf.

  • Constructor Details

    • IsTestProgram

      public IsTestProgram()
  • Method Details

    • test

      public boolean test(ISymbol symbol)
      Whether this symbol is itself a @Test program.

      This is the direct question, correct for callers already holding a program aggregate — which is most of them, since programs are what AllProgramsSupplier yields.

      Specified by:
      test in interface Predicate<ISymbol>
      Parameters:
      symbol - any symbol, or null
      Returns:
      true when the symbol carries the test marker