Files
whetstone_DSL/editor/tests/step1955_test.cpp
Bill 8c5fb9a6ad Sprint 285: poly-everything (steps 1953–1957)
Final Phase 5 sprint: unified polyglot orchestration over 8 languages
(C++, Python, Rust, Go, Haskell, TypeScript, Java, Lisp)

Components:
- PolyglotFunctionMap: (language, functionName) → implementation tag registry
- PolyglotExecutionContext: per-language runtime config (timeout_ms/env/working_dir)
- PolyglotResultAggregator: FunctionResult collection + AggregateReport (pass/fail/duration)
- PolyglotOrchestrator: ties all three; recordResult; runSummary

26/26 tests pass. Phase 5 (The Proof) complete.

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

92 lines
2.9 KiB
C++

// Step 1955: PolyglotResultAggregator
//
// t1: addResult and totalCount
// t2: aggregateReport pass/fail counts
// t3: aggregateReport failedLanguages
// t4: aggregateReport totalDurationMs
// t5: resultsForLanguage and clear
#include "PolyglotResultAggregator.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(addResult_and_totalCount);
ws::PolyglotResultAggregator a;
C(a.totalCount() == 0, "empty initially");
a.addResult({"Python","compute","42\n",true, 100});
a.addResult({"Rust", "compute","42\n",true, 80});
C(a.totalCount() == 2, "two results");
P();
}
void t2(){
T(aggregateReport_pass_fail_counts);
ws::PolyglotResultAggregator a;
a.addResult({"Python","fn","ok\n", true, 100});
a.addResult({"Rust", "fn","ok\n", true, 90});
a.addResult({"Go", "fn","err\n", false, 50});
auto r = a.aggregateReport();
C(r.totalCount == 3, "totalCount 3");
C(r.passCount == 2, "passCount 2");
C(r.failCount == 1, "failCount 1");
P();
}
void t3(){
T(aggregateReport_failedLanguages);
ws::PolyglotResultAggregator a;
a.addResult({"Haskell", "fn","ok\n", true, 200});
a.addResult({"TypeScript", "fn","err\n",false, 300});
a.addResult({"Java", "fn","err\n",false, 150});
auto r = a.aggregateReport();
C(r.failedLanguages.size() == 2, "two failed languages");
bool hasTs = false, hasJava = false;
for (const auto& l : r.failedLanguages) {
if (l == "TypeScript") hasTs = true;
if (l == "Java") hasJava = true;
}
C(hasTs && hasJava, "TypeScript and Java failed");
P();
}
void t4(){
T(aggregateReport_totalDurationMs);
ws::PolyglotResultAggregator a;
a.addResult({"Python","fn","",true,100});
a.addResult({"Rust", "fn","",true,200});
a.addResult({"Go", "fn","",true,300});
auto r = a.aggregateReport();
C(r.totalDurationMs == 600, "totalDurationMs 600");
P();
}
void t5(){
T(resultsForLanguage_and_clear);
ws::PolyglotResultAggregator a;
a.addResult({"Python","compute","42\n",true, 100});
a.addResult({"Python","format", "x\n", true, 50});
a.addResult({"Rust", "compute","42\n",true, 80});
auto pyResults = a.resultsForLanguage("Python");
C(pyResults.size() == 2, "two Python results");
auto rsResults = a.resultsForLanguage("Rust");
C(rsResults.size() == 1, "one Rust result");
C(a.resultsForLanguage("Go").empty(), "no Go results");
a.clear();
C(a.totalCount() == 0, "empty after clear");
P();
}
int main(){
std::cout << "Step 1955: PolyglotResultAggregator\n";
t1(); t2(); t3(); t4(); t5();
std::cout << "\n" << p << "/" << (p+f) << " passed\n";
return f > 0 ? 1 : 0;
}