Sprint 280: Cross-language step + breakpoints (steps 1928–1932)
CrossLanguageStepOverHandler, CrossLanguageStepIntoHandler, ASTNodeBreakpointMapper, BreakpointSyncOrchestrator — 26/26 tests pass. Integration step 1932: Go+TypeScript poly-API round-trip verified. Metrics: 7 whetstone calls, 5587 tokens. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
105
editor/tests/step1929_test.cpp
Normal file
105
editor/tests/step1929_test.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
// Step 1929: CrossLanguageStepIntoHandler
|
||||
//
|
||||
// t1: stepInto at non-boundary returns switched=false
|
||||
// t2: stepInto at boundary with different next language switches adapter
|
||||
// t3: stepInto returns correct targetFrameId
|
||||
// t4: stepInto at boundary where next frame is same language: no switch
|
||||
// t5: stepInto at last frame (no next): no switch
|
||||
|
||||
#include "CrossLanguageStepIntoHandler.h"
|
||||
#include "PolyglotStackTraceDecoder.h"
|
||||
#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;}
|
||||
|
||||
static ws::DebugAdapterRouter makeRouter() {
|
||||
ws::DebugAdapterRouter r;
|
||||
r.registerAdapter("Python", {"stackTrace","stepIn"});
|
||||
r.registerAdapter("Rust", {"stackTrace"});
|
||||
r.setActiveLanguage("Python");
|
||||
return r;
|
||||
}
|
||||
|
||||
static std::vector<ws::StackFrame> makeStack() {
|
||||
ws::PolyglotStackTraceDecoder dec;
|
||||
return dec.decode({
|
||||
{1,"run", "main.py", 10},
|
||||
{2,"generate", "gen.py", 20}, // boundary
|
||||
{3,"sort_array","sort.rs", 5}, // boundary
|
||||
{4,"partition", "sort.rs", 15},
|
||||
});
|
||||
}
|
||||
|
||||
void t1(){
|
||||
T(non_boundary_no_switch);
|
||||
ws::CrossLanguageStepIntoHandler h;
|
||||
auto router = makeRouter();
|
||||
auto frames = makeStack();
|
||||
auto r = h.stepInto(frames[0], router, frames, 0);
|
||||
C(!r.switched, "not switched");
|
||||
C(r.targetFrameId == -1, "no target frame");
|
||||
C(router.getActiveLanguage() == "Python", "router unchanged");
|
||||
P();
|
||||
}
|
||||
|
||||
void t2(){
|
||||
T(boundary_with_different_next_switches_adapter);
|
||||
ws::CrossLanguageStepIntoHandler h;
|
||||
auto router = makeRouter();
|
||||
auto frames = makeStack();
|
||||
// frames[1] is Python boundary, frames[2] is Rust
|
||||
auto r = h.stepInto(frames[1], router, frames, 1);
|
||||
C( r.switched, "switched");
|
||||
C( r.previousLanguage == "Python", "previous Python");
|
||||
C( r.newLanguage == "Rust", "new Rust");
|
||||
C( router.getActiveLanguage() == "Rust", "router now Rust");
|
||||
P();
|
||||
}
|
||||
|
||||
void t3(){
|
||||
T(returns_correct_targetFrameId);
|
||||
ws::CrossLanguageStepIntoHandler h;
|
||||
auto router = makeRouter();
|
||||
auto frames = makeStack();
|
||||
auto r = h.stepInto(frames[1], router, frames, 1);
|
||||
C(r.targetFrameId == frames[2].id, "targetFrameId == frames[2].id");
|
||||
C(r.targetFrameId == 3, "targetFrameId == 3");
|
||||
P();
|
||||
}
|
||||
|
||||
void t4(){
|
||||
T(boundary_but_same_language_next_no_switch);
|
||||
ws::CrossLanguageStepIntoHandler h;
|
||||
// frames[2] is Rust boundary, frames[3] is also Rust → no switch
|
||||
auto router = makeRouter();
|
||||
auto frames = makeStack();
|
||||
auto r = h.stepInto(frames[2], router, frames, 2);
|
||||
C(!r.switched, "not switched (same language)");
|
||||
C(r.targetFrameId == -1,"no target");
|
||||
P();
|
||||
}
|
||||
|
||||
void t5(){
|
||||
T(last_frame_no_next_no_switch);
|
||||
ws::CrossLanguageStepIntoHandler h;
|
||||
auto router = makeRouter();
|
||||
auto frames = makeStack();
|
||||
int last = static_cast<int>(frames.size()) - 1;
|
||||
auto r = h.stepInto(frames[last], router, frames, last);
|
||||
C(!r.switched, "no switch at last frame");
|
||||
C(r.targetFrameId == -1,"no target frame");
|
||||
P();
|
||||
}
|
||||
|
||||
int main(){
|
||||
std::cout << "Step 1929: CrossLanguageStepIntoHandler\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