Sprint 282: Polyglot test harness (steps 1938–1942)
PolyglotSpecRunner, BehavioralParityChecker, ParityRegressionGuard, PolyglotSuiteOrchestrator — 26/26 tests pass. Integration step 1942: poly-sort Python+Rust+Go parity verified. Metrics: 7 whetstone calls, 8855 tokens. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
100
editor/tests/step1940_test.cpp
Normal file
100
editor/tests/step1940_test.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
// Step 1940: ParityRegressionGuard
|
||||
//
|
||||
// t1: approve and isApproved/approvedCount
|
||||
// t2: guard — all match baseline → passed=true, empty regressions/newLanguages
|
||||
// t3: guard — output changed → regression detected
|
||||
// t4: guard — unapproved language in results → newLanguages
|
||||
// t5: updateBaseline changes expected output
|
||||
|
||||
#include "ParityRegressionGuard.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(approve_and_metadata);
|
||||
ws::ParityRegressionGuard g;
|
||||
g.approve("sort","Python","1 2 3\n");
|
||||
g.approve("sort","Rust", "1 2 3\n");
|
||||
C( g.isApproved("sort","Python"), "Python approved");
|
||||
C( g.isApproved("sort","Rust"), "Rust approved");
|
||||
C(!g.isApproved("sort","Go"), "Go not approved");
|
||||
C( g.approvedCount("sort") == 2, "two approved");
|
||||
C( g.approvedCount("other") == 0, "other zero");
|
||||
P();
|
||||
}
|
||||
|
||||
void t2(){
|
||||
T(guard_all_match_passes);
|
||||
ws::ParityRegressionGuard g;
|
||||
g.approve("sort","Python","1 2 3\n");
|
||||
g.approve("sort","Rust", "1 2 3\n");
|
||||
std::vector<ws::RunResult> results = {
|
||||
{"Python","1 2 3\n",0,true},
|
||||
{"Rust", "1 2 3\n",0,true}
|
||||
};
|
||||
auto r = g.guard("sort", results);
|
||||
C(r.passed, "passed");
|
||||
C(r.regressions.empty(), "no regressions");
|
||||
C(r.newLanguages.empty(),"no new languages");
|
||||
P();
|
||||
}
|
||||
|
||||
void t3(){
|
||||
T(guard_detects_regression);
|
||||
ws::ParityRegressionGuard g;
|
||||
g.approve("sort","Python","1 2 3\n");
|
||||
g.approve("sort","Rust", "1 2 3\n");
|
||||
std::vector<ws::RunResult> results = {
|
||||
{"Python","1 2 3\n",0,true},
|
||||
{"Rust", "3 2 1\n",0,true} // regression!
|
||||
};
|
||||
auto r = g.guard("sort", results);
|
||||
C(!r.passed, "not passed");
|
||||
C(r.regressions.size()==1, "one regression");
|
||||
C(r.regressions[0]=="Rust","Rust regressed");
|
||||
P();
|
||||
}
|
||||
|
||||
void t4(){
|
||||
T(guard_new_language_not_approved);
|
||||
ws::ParityRegressionGuard g;
|
||||
g.approve("sort","Python","ok\n");
|
||||
std::vector<ws::RunResult> results = {
|
||||
{"Python","ok\n",0,true},
|
||||
{"Go", "ok\n",0,true} // Go not approved
|
||||
};
|
||||
auto r = g.guard("sort", results);
|
||||
C(r.passed, "passed (no regressions)");
|
||||
C(r.newLanguages.size()==1,"one new language");
|
||||
C(r.newLanguages[0]=="Go", "Go is new");
|
||||
P();
|
||||
}
|
||||
|
||||
void t5(){
|
||||
T(updateBaseline_changes_expected);
|
||||
ws::ParityRegressionGuard g;
|
||||
g.approve("sort","Rust","1 2 3\n");
|
||||
g.updateBaseline("sort","Rust","sorted\n");
|
||||
// old output now regresses
|
||||
std::vector<ws::RunResult> results = {{"Rust","1 2 3\n",0,true}};
|
||||
auto r1 = g.guard("sort", results);
|
||||
C(!r1.passed, "old output is now regression");
|
||||
// new output passes
|
||||
std::vector<ws::RunResult> results2 = {{"Rust","sorted\n",0,true}};
|
||||
auto r2 = g.guard("sort", results2);
|
||||
C(r2.passed, "new baseline passes");
|
||||
P();
|
||||
}
|
||||
|
||||
int main(){
|
||||
std::cout << "Step 1940: ParityRegressionGuard\n";
|
||||
t1(); t2(); t3(); t4(); t5();
|
||||
std::cout << "\n" << p << "/" << (p+f) << " passed\n";
|
||||
return f > 0 ? 1 : 0;
|
||||
}
|
||||
Reference in New Issue
Block a user