Files
whetstone_DSL/editor/tests/step1962_test.cpp

93 lines
3.7 KiB
C++
Raw Normal View History

// Step 1962: Sprint 286 Integration
//
// t1: buildSeedLedger() contains entries for all 8 libraries
// t2: score("cublas", "compute.matrix") == 0.99
// t3: score("protobuf", "serialization.json") == 0.60 (not 0.95)
// t4: score("unknown_lib", "unknown_domain") == 0.0
// t5: Sprint286IntegrationSummary metadata correct
#include "Sprint286IntegrationSummary.h"
#include <iostream>
#include <algorithm>
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(seed_ledger_has_all_8_libraries);
auto ledger = ws::Sprint286IntegrationSummary::buildSeedLedger();
auto libs = ledger.libraries();
auto has = [&](const std::string& lib) {
return std::find(libs.begin(), libs.end(), lib) != libs.end();
};
C(has("nlohmann_json"), "nlohmann_json");
C(has("protobuf"), "protobuf");
C(has("serde_json"), "serde_json");
C(has("cublas"), "cublas");
C(has("thrust"), "thrust");
C(has("numpy"), "numpy");
C(has("tokio"), "tokio");
C(has("boost.asio"), "boost.asio");
C(libs.size() == 8, "exactly 8 libraries");
P();
}
void t2() {
T(cublas_compute_matrix_score_0_99);
auto ledger = ws::Sprint286IntegrationSummary::buildSeedLedger();
float s = ledger.score("cublas", "compute.matrix");
C(s == 0.99f, "cublas/compute.matrix == 0.99, got " + std::to_string(s));
// Also check that preferredAPIs are set
auto rec = ledger.get("cublas", "compute.matrix");
C(rec.has_value(), "record present");
C(!rec->preferredAPIs.empty(), "preferredAPIs not empty");
P();
}
void t3() {
T(protobuf_serialization_json_score_0_60_not_0_95);
auto ledger = ws::Sprint286IntegrationSummary::buildSeedLedger();
float json_score = ledger.score("protobuf", "serialization.json");
float binary_score = ledger.score("protobuf", "serialization.binary");
C(json_score == 0.60f, "serialization.json == 0.60, got " + std::to_string(json_score));
C(binary_score == 0.95f, "serialization.binary == 0.95, got " + std::to_string(binary_score));
// Domain specificity: json != binary
C(json_score != binary_score, "json and binary scores differ");
P();
}
void t4() {
T(unknown_pair_returns_zero);
auto ledger = ws::Sprint286IntegrationSummary::buildSeedLedger();
C(ledger.score("unknown_lib", "unknown_domain") == 0.0f, "both unknown");
C(ledger.score("cublas", "serialization.json") == 0.0f, "cublas no json score");
C(!ledger.has("unknown_lib", "compute.matrix"), "has() false for unknown");
// verifyLookups must pass
C(ws::Sprint286IntegrationSummary::verifyLookups(ledger), "verifyLookups passes");
P();
}
void t5() {
T(sprint286_integration_summary_metadata);
ws::Sprint286IntegrationSummary s;
C(s.stepsCompleted == 5, "5 steps");
C(s.success, "success flag");
C(s.sprintName() == "Sprint 286: OperationTaxonomy + LibraryCapabilityLedger", "name");
// Total seed records: nlohmann(1) + protobuf(2) + serde(1) + cublas(1) +
// thrust(1) + numpy(2) + tokio(2) + boost.asio(2) = 12
auto ledger = ws::Sprint286IntegrationSummary::buildSeedLedger();
C(ledger.size() == 12, "12 total seed records, got " + std::to_string(ledger.size()));
P();
}
int main() {
std::cout << "Step 1962: Sprint 286 Integration\n";
t1(); t2(); t3(); t4(); t5();
std::cout << "\n" << p << "/" << (p + f) << " passed\n";
return f > 0 ? 1 : 0;
}