File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,11 @@ runtime::Error Module::load(const runtime::Program::Verification verification) {
164
164
return runtime::Error::Ok;
165
165
}
166
166
167
+ runtime::Result<size_t > Module::num_methods () {
168
+ ET_CHECK_OK_OR_RETURN_ERROR (load ());
169
+ return program_->num_methods ();
170
+ }
171
+
167
172
runtime::Result<std::unordered_set<std::string>> Module::method_names () {
168
173
ET_CHECK_OK_OR_RETURN_ERROR (load ());
169
174
const auto method_count = program_->num_methods ();
Original file line number Diff line number Diff line change @@ -138,6 +138,14 @@ class Module {
138
138
return program_;
139
139
}
140
140
141
+ /* *
142
+ * Get the number of methods available in the loaded program.
143
+ *
144
+ * @returns A Result object containing either the number of methods available
145
+ * or an error to indicate failure.
146
+ */
147
+ runtime::Result<size_t > num_methods ();
148
+
141
149
/* *
142
150
* Get a list of method names available in the loaded program.
143
151
* Loads the program and method if needed.
Original file line number Diff line number Diff line change @@ -69,6 +69,14 @@ TEST_F(ModuleTest, TestMethodNames) {
69
69
EXPECT_EQ (method_names.get (), std::unordered_set<std::string>{" forward" });
70
70
}
71
71
72
+ TEST_F (ModuleTest, TestNumMethods) {
73
+ Module module (model_path_);
74
+
75
+ const auto num_methods = module .num_methods ();
76
+ EXPECT_EQ (num_methods.error (), Error::Ok);
77
+ EXPECT_EQ (num_methods.get (), 1 );
78
+ }
79
+
72
80
TEST_F (ModuleTest, TestNonExistentMethodNames) {
73
81
Module module (" /path/to/nonexistent/file.pte" );
74
82
You can’t perform that action at this time.
0 commit comments