// Step 1905: SymbolIndexUpdater // Incremental update of CrossLanguageSymbolTable on re-generation. // Avoids full rebuild: only removes stale entries, inserts new/changed ones. // // t1: update with same nodes is a no-op (table unchanged) // t2: adding a new node inserts it without disturbing existing entries // t3: removing a node (not in new set) removes it from the table // t4: changed node (same name, different languages) replaces old entry // t5: updateResult reports added, removed, unchanged counts correctly #include "SymbolIndexUpdater.h" #include "CrossLanguageSymbolTable.h" #include "ABIBoundaryExtractor.h" #include #include 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: "<= 1 || result.removed >= 1, "change should register as add+remove or net change"); C(table.contains("Python", "compute"), "compute still in Python"); P(); } void t5(){ T(update_result_counts_correctly); ws::CrossLanguageSymbolTable table; auto n1 = makeNode("fn_a", "Python", "Rust", "from-a", "to-a"); auto n2 = makeNode("fn_b", "Go", "C++", "from-b", "to-b"); auto n3 = makeNode("fn_c", "Go", "Rust", "from-c", "to-c"); table.insert(n1); table.insert(n2); // n1 unchanged, n2 removed, n3 added auto result = ws::SymbolIndexUpdater::update(table, {n1, n2}, {n1, n3}); C(result.added == 1, "added must be 1 (fn_c)"); C(result.removed == 1, "removed must be 1 (fn_b)"); C(result.unchanged == 1, "unchanged must be 1 (fn_a)"); P(); } int main(){ std::cout << "Step 1905: SymbolIndexUpdater\n"; t1(); t2(); t3(); t4(); t5(); std::cout << "\n" << p << "/" << (p+f) << " passed\n"; return f > 0 ? 1 : 0; }