108 lines
3.9 KiB
C++
108 lines
3.9 KiB
C++
|
|
// Step 1942: Sprint 282 Integration — poly-sort: Python+Rust+Go parity
|
||
|
|
//
|
||
|
|
// Scenario: "sort" AST node has three language variants.
|
||
|
|
// - Python, Rust, Go all produce identical output "1 2 3\n".
|
||
|
|
// - BehavioralParityChecker confirms all match.
|
||
|
|
// - ParityRegressionGuard passes after approval.
|
||
|
|
// - PolyglotSuiteOrchestrator reports overallPass=true.
|
||
|
|
// - Adding a fourth language (Haskell) with different output fails parity.
|
||
|
|
// - Sprint282IntegrationSummary reports 5 steps complete.
|
||
|
|
//
|
||
|
|
// t1: three-language parity all match
|
||
|
|
// t2: suite orchestrator overallPass on matching variants
|
||
|
|
// t3: adding diverging variant fails parity
|
||
|
|
// t4: guard regression detected when output changes post-approval
|
||
|
|
// t5: Sprint282IntegrationSummary reports success
|
||
|
|
|
||
|
|
#include "PolyglotSuiteOrchestrator.h"
|
||
|
|
#include "BehavioralParityChecker.h"
|
||
|
|
#include "ParityRegressionGuard.h"
|
||
|
|
#include "PolyglotSpecRunner.h"
|
||
|
|
#include "Sprint282IntegrationSummary.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;}
|
||
|
|
|
||
|
|
static const std::string SORTED = "1 2 3\n";
|
||
|
|
|
||
|
|
void t1(){
|
||
|
|
T(three_language_parity_all_match);
|
||
|
|
ws::PolyglotSpecRunner runner;
|
||
|
|
runner.registerVariant("sort","Python","sort.py");
|
||
|
|
runner.registerVariant("sort","Rust", "sort");
|
||
|
|
runner.registerVariant("sort","Go", "sort_go");
|
||
|
|
runner.recordOutput("sort","Python",SORTED);
|
||
|
|
runner.recordOutput("sort","Rust", SORTED);
|
||
|
|
runner.recordOutput("sort","Go", SORTED);
|
||
|
|
auto results = runner.runAll("sort","3 1 2");
|
||
|
|
ws::BehavioralParityChecker checker;
|
||
|
|
auto report = checker.check(results);
|
||
|
|
C(report.allMatch, "all match");
|
||
|
|
C(report.divergentLanguages.empty(), "no divergents");
|
||
|
|
C(checker.allPass(results), "allPass");
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
void t2(){
|
||
|
|
T(suite_orchestrator_overallPass_matching);
|
||
|
|
ws::PolyglotSuiteOrchestrator o;
|
||
|
|
for (auto& lang : {"Python","Rust","Go"}) {
|
||
|
|
o.addVariant("sort", lang, lang);
|
||
|
|
o.recordExpected("sort", lang, SORTED);
|
||
|
|
o.approveBaseline("sort", lang, SORTED);
|
||
|
|
}
|
||
|
|
auto sr = o.run("sort","3 1 2");
|
||
|
|
C(sr.overallPass, "overallPass");
|
||
|
|
C(sr.parity.allMatch, "parity allMatch");
|
||
|
|
C(sr.guard.passed, "guard passed");
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
void t3(){
|
||
|
|
T(diverging_variant_fails_parity);
|
||
|
|
ws::PolyglotSuiteOrchestrator o;
|
||
|
|
o.addVariant("sort","Python","p"); o.recordExpected("sort","Python",SORTED);
|
||
|
|
o.addVariant("sort","Rust", "r"); o.recordExpected("sort","Rust", SORTED);
|
||
|
|
o.addVariant("sort","Haskell","h"); o.recordExpected("sort","Haskell","3 2 1\n"); // diverges
|
||
|
|
o.approveBaseline("sort","Python",SORTED);
|
||
|
|
o.approveBaseline("sort","Rust", SORTED);
|
||
|
|
o.approveBaseline("sort","Haskell","3 2 1\n");
|
||
|
|
auto sr = o.run("sort","");
|
||
|
|
C(!sr.parity.allMatch, "parity fails");
|
||
|
|
C(!sr.overallPass, "overallPass false");
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
void t4(){
|
||
|
|
T(guard_regression_after_output_change);
|
||
|
|
ws::PolyglotSuiteOrchestrator o;
|
||
|
|
o.addVariant("sort","Rust","r");
|
||
|
|
o.recordExpected("sort","Rust","new_output\n");
|
||
|
|
o.approveBaseline("sort","Rust",SORTED); // old baseline
|
||
|
|
auto sr = o.run("sort","");
|
||
|
|
C(!sr.guard.passed, "guard regression detected");
|
||
|
|
C(!sr.overallPass, "overallPass false");
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
void t5(){
|
||
|
|
T(sprint282_integration_summary);
|
||
|
|
ws::Sprint282IntegrationSummary s;
|
||
|
|
C(s.stepsCompleted == 5, "5 steps");
|
||
|
|
C(s.success, "success");
|
||
|
|
C(s.sprintName() == "Sprint 282: Polyglot Test Harness", "name");
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
int main(){
|
||
|
|
std::cout << "Step 1942: Sprint 282 Integration\n";
|
||
|
|
t1(); t2(); t3(); t4(); t5();
|
||
|
|
std::cout << "\n" << p << "/" << (p+f) << " passed\n";
|
||
|
|
return f > 0 ? 1 : 0;
|
||
|
|
}
|