Files
whetstone_DSL/editor/tests/step1924_test.cpp
Bill 3808caa1d5 Sprint 279: DAP Orchestration Core (steps 1923-1927)
- DAPProxyServer: DAP JSON dispatcher, routes by command, default handlers for
  all standard DAP commands, response envelope with seq/type/request_seq/success
- DebugAdapterRouter: per-language adapter capability registry; routeCommand gates
  on active language AND adapter support
- PolyglotStackTraceDecoder: infers language from source extension, marks boundary
  frames where adjacent frames differ in language, sets astNodeId per frame
- LanguageSeamFrameDetector: detectSeams/primarySeam/seamCount/frameLanguages/
  crossesBoundary over decoded polyglot stacks
- Sprint279IntegrationSummary: poly-sort (Python+Rust) end-to-end DAP pipeline

26/26 tests passing (5+5+5+5+6). All new headers well under 600 lines.
LoRA recorded: sprint279-2026-03-01 (7 calls, 5535 tokens).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01 21:08:37 -07:00

93 lines
3.4 KiB
C++

// Step 1924: DebugAdapterRouter
// Routes DAP commands to the correct language debug adapter.
//
// t1: setActiveLanguage / getActiveLanguage
// t2: registerAdapter and adapterSupports
// t3: routeCommand true only when active language AND supports command
// t4: adaptersSupporting finds all langs with a command
// t5: registeredAdapters lists all registered languages
#include "DebugAdapterRouter.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(setActiveLanguage_getActiveLanguage);
ws::DebugAdapterRouter r;
C(r.getActiveLanguage().empty(), "empty initially");
r.setActiveLanguage("Python");
C(r.getActiveLanguage() == "Python", "Python active");
r.setActiveLanguage("Rust");
C(r.getActiveLanguage() == "Rust", "Rust active after switch");
P();
}
void t2(){
T(registerAdapter_and_adapterSupports);
ws::DebugAdapterRouter r;
r.registerAdapter("Python", {"stackTrace","scopes","variables","continue","next","stepIn"});
r.registerAdapter("Rust", {"stackTrace","scopes","variables","continue","next"});
C( r.adapterSupports("Python","stepIn"), "Python supports stepIn");
C(!r.adapterSupports("Rust", "stepIn"), "Rust lacks stepIn");
C( r.adapterSupports("Rust", "continue"),"Rust supports continue");
C(!r.adapterSupports("Go", "stackTrace"),"unregistered Go lacks stackTrace");
P();
}
void t3(){
T(routeCommand_active_and_supports);
ws::DebugAdapterRouter r;
r.registerAdapter("Python", {"stackTrace","continue","stepIn"});
r.registerAdapter("Rust", {"stackTrace","continue"});
r.setActiveLanguage("Python");
// active + supports → true
C( r.routeCommand("stackTrace","Python"), "Python active stackTrace");
C( r.routeCommand("stepIn", "Python"), "Python active stepIn");
// active but other lang → false
C(!r.routeCommand("stackTrace","Rust"), "Rust not active → false");
// switch active
r.setActiveLanguage("Rust");
C( r.routeCommand("stackTrace","Rust"), "Rust now active stackTrace");
C(!r.routeCommand("stepIn", "Rust"), "Rust active but lacks stepIn");
C(!r.routeCommand("stackTrace","Python"), "Python no longer active");
P();
}
void t4(){
T(adaptersSupporting_finds_all);
ws::DebugAdapterRouter r;
r.registerAdapter("Python", {"stackTrace","continue","stepIn"});
r.registerAdapter("Rust", {"stackTrace","continue"});
r.registerAdapter("Go", {"stackTrace","continue","next"});
auto st = r.adaptersSupporting("stackTrace");
C(st.size() == 3, "three adapters support stackTrace");
auto si = r.adaptersSupporting("stepIn");
C(si.size() == 1 && si[0] == "Python", "only Python supports stepIn");
C(r.adaptersSupporting("attach").empty(), "none support attach");
P();
}
void t5(){
T(registeredAdapters_lists_all);
ws::DebugAdapterRouter r;
C(r.registeredAdapters().empty(), "empty initially");
r.registerAdapter("Python", {"continue"});
r.registerAdapter("Rust", {"continue"});
C(r.registeredAdapters().size() == 2, "two registered");
P();
}
int main(){
std::cout << "Step 1924: DebugAdapterRouter\n";
t1(); t2(); t3(); t4(); t5();
std::cout << "\n" << p << "/" << (p+f) << " passed\n";
return f > 0 ? 1 : 0;
}