21 lines
2.0 KiB
C++
21 lines
2.0 KiB
C++
|
|
// Step 764: Async model bridge (10 tests)
|
||
|
|
#include "managed/AsyncModelBridge.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 ManagedLoweringPacket mk(int asyncSignals){ManagedLoweringPacket x; x.asyncSignalCount=asyncSignals; return x;}
|
||
|
|
void t1(){T(source_model_kotlin);auto x=AsyncModelBridge::plan("kotlin","csharp",mk(1));C(x.sourceModel=="coroutines","src");P();}
|
||
|
|
void t2(){T(source_model_non_kotlin);auto x=AsyncModelBridge::plan("csharp","kotlin",mk(1));C(x.sourceModel=="task","src");P();}
|
||
|
|
void t3(){T(target_model_kotlin);auto x=AsyncModelBridge::plan("csharp","kotlin",mk(1));C(x.targetModel=="coroutines","tgt");P();}
|
||
|
|
void t4(){T(target_model_non_kotlin);auto x=AsyncModelBridge::plan("kotlin","csharp",mk(1));C(x.targetModel=="task","tgt");P();}
|
||
|
|
void t5(){T(runtime_shim_for_cross_model);auto x=AsyncModelBridge::plan("kotlin","csharp",mk(1));C(x.runtimeShimRequired,"shim");P();}
|
||
|
|
void t6(){T(no_shim_when_no_async);auto x=AsyncModelBridge::plan("kotlin","csharp",mk(0));C(!x.runtimeShimRequired,"shim");P();}
|
||
|
|
void t7(){T(strategy_adapter_shim);auto x=AsyncModelBridge::plan("kotlin","csharp",mk(1));C(x.bridgeStrategy=="adapter_shim","strategy");P();}
|
||
|
|
void t8(){T(strategy_direct_mapping);auto x=AsyncModelBridge::plan("csharp","vbnet",mk(1));C(x.bridgeStrategy=="direct_mapping","strategy");P();}
|
||
|
|
void t9(){T(json_shape);auto j=AsyncModelBridge::toJson(AsyncModelBridge::plan("csharp","vbnet",mk(1)));C(j.contains("source_model")&&j.contains("bridge_strategy"),"shape");P();}
|
||
|
|
void t10(){T(deterministic);auto a=AsyncModelBridge::toJson(AsyncModelBridge::plan("kotlin","csharp",mk(1))).dump();auto b=AsyncModelBridge::toJson(AsyncModelBridge::plan("kotlin","csharp",mk(1))).dump();C(a==b,"det");P();}
|
||
|
|
int main(){std::cout<<"Step 764: AsyncModelBridge\n";t1();t2();t3();t4();t5();t6();t7();t8();t9();t10();std::cout<<"\nResults: "<<p<<"/"<<(p+f)<<" passed\n";return f?1:0;}
|