Skip to content

Commit 0165a02

Browse files
authored
Add virtual keyword to Module methods to make it Mock-able
Differential Revision: D73703574 Pull Request resolved: #10521
1 parent 66314e4 commit 0165a02

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

extension/module/module.h

+4-6
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class Module {
110110
Module& operator=(const Module&) = delete;
111111
Module(Module&&) = delete;
112112
Module& operator=(Module&&) = delete;
113-
113+
virtual ~Module() = default;
114114
/**
115115
* Loads the program if needed.
116116
*
@@ -119,8 +119,7 @@ class Module {
119119
*
120120
* @returns An Error to indicate success or failure of the loading process.
121121
*/
122-
ET_NODISCARD
123-
runtime::Error load(
122+
ET_NODISCARD virtual runtime::Error load(
124123
const Program::Verification verification =
125124
Program::Verification::Minimal);
126125

@@ -129,7 +128,7 @@ class Module {
129128
*
130129
* @returns true if the program is loaded, false otherwise.
131130
*/
132-
inline bool is_loaded() const {
131+
virtual inline bool is_loaded() const {
133132
return program_ != nullptr;
134133
}
135134

@@ -242,8 +241,7 @@ class Module {
242241
* @returns A Result object containing either a vector of output values
243242
* from the method or an error to indicate failure.
244243
*/
245-
ET_NODISCARD
246-
runtime::Result<std::vector<runtime::EValue>> execute(
244+
ET_NODISCARD virtual runtime::Result<std::vector<runtime::EValue>> execute(
247245
const std::string& method_name,
248246
const std::vector<runtime::EValue>& input_values);
249247

0 commit comments

Comments
 (0)