Sprints 46-58 implement the cross-language porting foundation: language-to-IR adapters, equivalence checking, gate validation, legacy ingestion, managed/dynamic families, low-level/logic-actor semantics, debug workflow tooling, AST-native family tools, Rust/CPP raising tools, system-level orchestration, query family, and porting gates. Sprint 59 adds the governance layer (policy packs, review boards, waiver packets, ambiguity triage, decision ledger) with the whetstone_review_porting_decision MCP tool. Also includes: sprint plans 46-130, MCP taskitem pipeline scripts, CLAUDE.md, docs, and full test matrix (steps 689-828). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
27 lines
2.0 KiB
C++
27 lines
2.0 KiB
C++
// Step 703: Error model lowering (10 tests)
|
|
|
|
#include "rust_ir/RustErrorModelLowering.h"
|
|
|
|
#include <iostream>
|
|
|
|
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 char* src = "fn f()->Result<Option<i32>,String>{ panic!(\"x\"); let x:Option<i32>=None; Err(\"e\".into())? }";
|
|
|
|
void t1(){T(result_detected);auto m=RustErrorModelLowering::lower(src);C(m.usesResult,"result missing");P();}
|
|
void t2(){T(option_detected);auto m=RustErrorModelLowering::lower(src);C(m.usesOption,"option missing");P();}
|
|
void t3(){T(panic_detected);auto m=RustErrorModelLowering::lower(src);C(m.usesPanic,"panic missing");P();}
|
|
void t4(){T(question_detected);auto m=RustErrorModelLowering::lower(src);C(m.usesQuestionOperator,"? missing");P();}
|
|
void t5(){T(empty_false);auto m=RustErrorModelLowering::lower("");C(!m.usesResult&&!m.usesOption&&!m.usesPanic&&!m.usesQuestionOperator,"expected false");P();}
|
|
void t6(){T(json_has_result);auto j=RustErrorModelLowering::toJson(RustErrorModelLowering::lower(src));C(j.contains("usesResult"),"usesResult missing");P();}
|
|
void t7(){T(json_has_option);auto j=RustErrorModelLowering::toJson(RustErrorModelLowering::lower(src));C(j.contains("usesOption"),"usesOption missing");P();}
|
|
void t8(){T(json_has_panic);auto j=RustErrorModelLowering::toJson(RustErrorModelLowering::lower(src));C(j.contains("usesPanic"),"usesPanic missing");P();}
|
|
void t9(){T(json_has_question);auto j=RustErrorModelLowering::toJson(RustErrorModelLowering::lower(src));C(j.contains("usesQuestionOperator"),"question missing");P();}
|
|
void t10(){T(deterministic);auto a=RustErrorModelLowering::toJson(RustErrorModelLowering::lower(src)).dump();auto b=RustErrorModelLowering::toJson(RustErrorModelLowering::lower(src)).dump();C(a==b,"nondeterministic");P();}
|
|
|
|
int main(){std::cout<<"Step 703: Error model lowering\n";t1();t2();t3();t4();t5();t6();t7();t8();t9();t10();std::cout<<"\nResults: "<<p<<"/"<<(p+f)<<" passed\n";return f?1:0;}
|