Files
whetstone_DSL/editor/tests/step1946_test.cpp
Bill 95cf04008e Sprint 283: poly-pipeline (steps 1943–1947)
PipelineStageSpec/Registry, PipelineGraph (Kahn topo sort), PipelineExecutionPlan,
PipelineParityValidator — 26/26 tests pass.
Integration step 1947: Python→Rust→Go→Haskell→TypeScript pipeline verified.
Metrics: 7 whetstone calls, 8566 tokens.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01 22:25:57 -07:00

91 lines
2.8 KiB
C++

// Step 1946: PipelineParityValidator
//
// t1: setReference and referenceCount
// t2: validate passes when all outputs match references
// t3: validate fails when output mismatches reference
// t4: validate fails when success=false regardless of output
// t5: stagePass correct; no reference set always passes
#include "PipelineParityValidator.h"
#include <iostream>
namespace ws = whetstone;
static int p=0,f=0;
#define T(n) { std::cout<<" "<<#n<<"... "; }
#define P() { std::cout<<"PASS\n"; ++p; }
#define F(m) { std::cout<<"FAIL: "<<m<<"\n"; ++f; }
#define C(c,m) if(!(c)){F(m);return;}
void t1(){
T(setReference_and_referenceCount);
ws::PipelineParityValidator v;
C(v.referenceCount() == 0, "zero initially");
v.setReference("ingest", "records\n");
v.setReference("normalize", "normed\n");
C(v.referenceCount() == 2, "two references");
P();
}
void t2(){
T(validate_passes_when_all_match);
ws::PipelineParityValidator v;
v.setReference("ingest","records\n");
v.setReference("norm", "normed\n");
std::vector<ws::StageOutput> outputs = {
{"ingest","Python","records\n",true},
{"norm", "Rust", "normed\n", true}
};
auto r = v.validate(outputs);
C(r.passed, "passed");
C(r.failedStages.empty(),"no failures");
P();
}
void t3(){
T(validate_fails_on_mismatch);
ws::PipelineParityValidator v;
v.setReference("norm","normed\n");
std::vector<ws::StageOutput> outputs = {
{"norm","Rust","WRONG\n",true}
};
auto r = v.validate(outputs);
C(!r.passed, "not passed");
C(r.failedStages.size()==1,"one failure");
C(r.failedStages[0]=="norm","norm failed");
P();
}
void t4(){
T(validate_fails_when_success_false);
ws::PipelineParityValidator v;
v.setReference("fanout","batches\n");
std::vector<ws::StageOutput> outputs = {
{"fanout","Go","batches\n",false} // success=false despite matching output
};
auto r = v.validate(outputs);
C(!r.passed, "not passed (success=false)");
C(r.failedStages[0]=="fanout","fanout failed");
// Stage with no reference but success=false also fails
std::vector<ws::StageOutput> outputs2 = {{"x","Go","anything",false}};
auto r2 = v.validate(outputs2);
C(!r2.passed, "no-ref stage fails when success=false");
P();
}
void t5(){
T(stagePass_with_and_without_reference);
ws::PipelineParityValidator v;
v.setReference("norm","normed\n");
C( v.stagePass("norm","normed\n"), "correct output passes");
C(!v.stagePass("norm","wrong\n"), "wrong output fails");
C( v.stagePass("unknown","anything"),"no reference always passes");
P();
}
int main(){
std::cout << "Step 1946: PipelineParityValidator\n";
t1(); t2(); t3(); t4(); t5();
std::cout << "\n" << p << "/" << (p+f) << " passed\n";
return f > 0 ? 1 : 0;
}