Skip to content

test: densify ctest suite — line coverage 86.4% → 93.1% (tests-only)#30

Merged
luisleo526 merged 2 commits into
mainfrom
tests/ctest-densification
Jun 4, 2026
Merged

test: densify ctest suite — line coverage 86.4% → 93.1% (tests-only)#30
luisleo526 merged 2 commits into
mainfrom
tests/ctest-densification

Conversation

@luisleo526

Copy link
Copy Markdown
Collaborator

Summary

Densifies the ctest unit suite so passing it more strongly underwrites "~95% of pinescript reproduced." Tests + coverage-tooling only — zero src//include/ changes.

  • ctest: 53 → 68 unit tests, 100% pass under the canonical Release (-DNDEBUG) gate.
  • Line coverage: 86.38% → 93.06% (+6.68 pts, 499 fewer missed lines).
  • TV corpus parity unchanged (245 excellent + 1 anomaly, no drift).

15 new tests target the lowest-covered translation units, pinning real Pine-correct behavior via closed-form OHLC oracles and na/warmup edge cases.

Per-TU line coverage

TU before after
c_abi 16% 100%
engine_report 73% 100%
ta_moving_averages 93% 100%
ta_extremes_volume 95% 99%
ta_oscillators 95% 99%
ta_volatility_trend 94% 97%
engine_strategy_commands 92% 96%
engine_fills 94% 96%
engine_lower_tf 88% 95%
engine_path_resolve 78% 94%
engine_run 79% 93%
engine_security 86% 93%
matrix 88% 98%
timeframe 89% 94%
session_time 68% 90%

NDEBUG-proof tests

The prescribed gate builds Release (-DNDEBUG), which no-ops bare assert() and makes assert-only tests pass vacuously. All new tests use a self-rolled CHECK + failure-counter return instead; non-vacuity was confirmed by corrupt-and-rebuild. (Note: the pre-existing test_security_tf_validation.cpp has this latent assert()/NDEBUG defect — flagged, out of scope here.)

Coverage tooling (scripts/)

  • coverage.sh: fix uncovered.txt sort key (was sorting by region cov col 4, now line cov col 10); capture llvm-cov's "N functions have mismatched data" warning — benign (header inline/template code instantiated across all test binaries with differing mapping hashes; the merge drops unmatched variants) — and replace it with a plain-language NOTE.
  • cov_union.py: on-demand per-binary union verifier for exact header line coverage (recovers the multi-binary undercount, e.g. generic_matrix.hpp ~77% reported → ~86% true). .cpp headline metric unchanged.

Verification

  • ctest 68/68 pass (Release).
  • scripts/run_corpus.sh parity unchanged.
  • No src/ or include/ diffs.

🤖 Generated with Claude Code

luisleo526 and others added 2 commits June 5, 2026 04:15
…union verifier

- coverage.sh: fix uncovered.txt sort key (region-cov col 4 -> line-cov col 10).
- coverage.sh: capture llvm-cov's "N functions have mismatched data" warning
  (benign: header inline/template code instantiated across all test binaries
  with differing mapping hashes; the merge drops unmatched variants) and replace
  it with a plain-language NOTE in totals.txt; silence duplicate emissions.
- cov_union.py: on-demand per-binary union verifier for exact header line
  coverage (recovers the multi-binary undercount, e.g. generic_matrix.hpp
  ~77% reported -> ~86% true). .cpp metric unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add 15 unit tests targeting the lowest-covered translation units, raising
line coverage from 86.38% to 93.06% (499 fewer missed lines). ctest 53 -> 68,
all pass under the canonical Release (-DNDEBUG) gate. No src/ or include/
changes; TV corpus parity unchanged (245 excellent + 1 anomaly).

All tests are NDEBUG-proof (self-rolled CHECK + failure-counter return, not
bare assert() which the Release gate would no-op) and pin real Pine-correct
behavior via closed-form OHLC oracles / na+warmup edges.

New per-TU coverage:
  engine_report 73->100, session_time 68->90, engine_run 79->93,
  engine_path_resolve 78->94, engine_security 86->93, matrix 88->98,
  timeframe 89->94, c_abi 16->100, ta_moving_averages 93->100,
  ta_extremes_volume 95->99, ta_oscillators 95->99, ta_volatility_trend 94->97,
  engine_strategy_commands 92->96, engine_fills 94->96, engine_lower_tf 88->95.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@luisleo526
luisleo526 merged commit 7fb78c1 into main Jun 4, 2026
5 checks passed
@luisleo526
luisleo526 deleted the tests/ctest-densification branch June 4, 2026 20:18
pull Bot referenced this pull request in Malumbo21/pineforge-engine Jul 2, 2026
…to calling-bar boundary

request.security(sym, tf, ta.<fn>(...)[k], lookahead=barmerge.lookahead_on)
where tf is FINER than the script/chart TF (e.g. so2TF="5" read from a 15m
chart) fed the read-before-push history-offset machinery (added for #30/#31)
one native-security-period value late instead of one CALLING-bar late: the
security's own aggregator completes R = script_seconds/requested_seconds
times per calling bar, and hist.push() fired (unconditionally on
is_complete) on every one of those completions, so hist[0] silently drifted
to "one security-period behind the LAST completion of THIS calling bar"
instead of "the last completion of the PREVIOUS calling bar".

Add SecurityEvalState::publish_gate_tf_seconds (validate_security_timeframes):
nonzero only for a plain (non-security_lower_tf) request.security whose
target TF is strictly finer than script_tf and evenly divides it. In
feed_security_eval_state's aggregator branch, gate the is_complete flag
passed to evaluate_security() on wall-clock bucket-end alignment with the
script_tf boundary, instead of passing the raw completion flag through
unconditionally. The underlying TA state (compute/recompute dispatch) is
driven by current_sub_bar_count, independent of this flag, so intermediate
completions still advance the indicator correctly -- only the exposed
history buffer's publish cadence changes. No-op (field stays 0) for every
coarser-or-equal-TF security and every request.security_lower_tf call.

3commas-3commas-triple-rsi-dca-long-risk-adjusted-averaging-strategy
(so2Rsi = request.security(sym, "5", ta.rsi(close,7)[1], lookahead=
barmerge.lookahead_on) on a 15m chart): 50.5% -> 100.0% match vs
TradingView (108/108 trades, 100% exact price). Full corpus
(252 strategies) + ctest (77) unchanged: excellent=251/anomaly=1,
tier-for-tier identical to baseline. Spot-checked every other
lookahead_on + history-offset request.security call site in the standard
corpus (6 other slugs, all coarser-than-chart target TFs, e.g. "D"/"W"/
240/60) -- byte-identical engine_trades.csv/engine_verify.json output,
confirming zero blast radius outside this one finer-than-chart case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant