2026-02-09 18:02:57 -07:00
|
|
|
// Step 143 TDD Test: Elisp function discovery and indexing
|
|
|
|
|
#include "EmacsFunctionDiscovery.h"
|
2026-02-11 01:34:27 +00:00
|
|
|
#include "NotificationSystem.h"
|
2026-02-09 18:02:57 -07:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
static void expect(bool cond, const std::string& name, int& passed, int& failed) {
|
|
|
|
|
if (cond) {
|
|
|
|
|
std::cout << "Test " << (passed + failed + 1) << " PASS: " << name << "\n";
|
|
|
|
|
++passed;
|
|
|
|
|
} else {
|
|
|
|
|
std::cout << "Test " << (passed + failed + 1) << " FAIL: " << name << "\n";
|
|
|
|
|
++failed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
int passed = 0;
|
|
|
|
|
int failed = 0;
|
|
|
|
|
|
|
|
|
|
MockEmacsConnection mock;
|
2026-02-11 01:34:27 +00:00
|
|
|
NotificationSystem notifications;
|
2026-02-09 18:02:57 -07:00
|
|
|
std::string error;
|
|
|
|
|
|
2026-02-11 01:34:27 +00:00
|
|
|
auto packages = queryEmacsPackageList(mock, false, notifications, error);
|
2026-02-09 18:02:57 -07:00
|
|
|
expect(!packages.empty(), "loaded packages fetched", passed, failed);
|
|
|
|
|
|
2026-02-11 01:34:27 +00:00
|
|
|
auto funcs = queryEmacsFunctions(mock, "^use-package", notifications);
|
2026-02-09 18:02:57 -07:00
|
|
|
expect(!funcs.empty(), "apropos returns functions", passed, failed);
|
|
|
|
|
|
2026-02-11 01:34:27 +00:00
|
|
|
auto doc = queryEmacsFunctionDoc(mock, "use-package", notifications);
|
2026-02-09 18:02:57 -07:00
|
|
|
expect(!doc.signature.empty(), "describe-function signature", passed, failed);
|
|
|
|
|
expect(!doc.doc.empty(), "describe-function docstring", passed, failed);
|
|
|
|
|
|
|
|
|
|
EmacsFunctionIndex index;
|
2026-02-11 01:34:27 +00:00
|
|
|
refreshEmacsFunctionIndex(index, mock, packages, notifications);
|
2026-02-09 18:02:57 -07:00
|
|
|
expect(index.functionsByPackage.count("use-package") > 0, "index contains use-package", passed, failed);
|
|
|
|
|
|
|
|
|
|
Module module("mod1", "test", "elisp");
|
|
|
|
|
int sigId = 0;
|
|
|
|
|
appendEmacsExternalModules(&module, index, sigId);
|
|
|
|
|
auto extMods = module.getChildren("externalModules");
|
|
|
|
|
expect(!extMods.empty(), "external modules appended", passed, failed);
|
|
|
|
|
|
|
|
|
|
LibraryIndexData libIndex;
|
|
|
|
|
addEmacsSymbolsToLibraryIndex(libIndex, index);
|
|
|
|
|
expect(libIndex.symbolsByLibrary.count("use-package") > 0, "library index updated", passed, failed);
|
|
|
|
|
|
|
|
|
|
std::cout << "\n=== Step 143 Results: " << passed << " passed, "
|
|
|
|
|
<< failed << " failed ===\n";
|
|
|
|
|
return failed == 0 ? 0 : 1;
|
|
|
|
|
}
|