mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-27 20:29:39 +02:00
refactor(dynamic): add recursive dependency resolution for C++ receivers, improve harness generation logic, and expand test coverage
This commit is contained in:
parent
8786d1b71e
commit
6e9cc0b607
4 changed files with 320 additions and 9 deletions
|
|
@ -249,6 +249,19 @@ fn class_method_cpp_constructs_default_then_calls_method() {
|
|||
assert!(h.source.contains("instance.run"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn class_method_cpp_builds_recursive_receiver_initializer() {
|
||||
let mut spec = make_spec(Lang::Cpp);
|
||||
spec.entry_file = "tests/dynamic_fixtures/class_method/cpp_recursive_deps/vuln.cpp".into();
|
||||
spec.sink_file = spec.entry_file.clone();
|
||||
let h = lang::emit(&spec).expect("emit ok");
|
||||
assert!(
|
||||
h.source
|
||||
.contains("UserService instance{CommandRunner{ShellRunner{}}};")
|
||||
);
|
||||
assert!(!h.source.contains("UserService instance;"));
|
||||
}
|
||||
|
||||
// ── End-to-end Phase 19 acceptance via run_spec ─────────────────────────────
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
// Benign control for recursive C++ class-method receiver construction.
|
||||
#include <string>
|
||||
|
||||
class ShellRunner {
|
||||
public:
|
||||
void exec(const std::string& _cmd) {}
|
||||
};
|
||||
|
||||
class CommandRunner {
|
||||
ShellRunner shell;
|
||||
|
||||
public:
|
||||
explicit CommandRunner(ShellRunner shell) : shell(shell) {}
|
||||
|
||||
void run(const std::string& input) {
|
||||
shell.exec(input);
|
||||
}
|
||||
};
|
||||
|
||||
class UserService {
|
||||
CommandRunner runner;
|
||||
|
||||
public:
|
||||
explicit UserService(CommandRunner runner) : runner(runner) {}
|
||||
|
||||
void run(const std::string& input) {
|
||||
runner.run(input);
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
// C++ class-method fixture whose receiver has same-file constructor
|
||||
// dependencies but no default constructor.
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
class ShellRunner {
|
||||
public:
|
||||
void exec(const std::string& cmd) {
|
||||
std::system(cmd.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
class CommandRunner {
|
||||
ShellRunner shell;
|
||||
|
||||
public:
|
||||
explicit CommandRunner(ShellRunner shell) : shell(shell) {}
|
||||
|
||||
void run(const std::string& input) {
|
||||
shell.exec(std::string("true ") + input);
|
||||
}
|
||||
};
|
||||
|
||||
class UserService {
|
||||
CommandRunner runner;
|
||||
|
||||
public:
|
||||
explicit UserService(CommandRunner runner) : runner(runner) {}
|
||||
|
||||
void run(const std::string& input) {
|
||||
runner.run(input);
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue