mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Add public API in the interpreter (Rust/C++) to obtain the list of functions
This commit is contained in:
parent
6f2a6c3f09
commit
37b63e4bd4
4 changed files with 100 additions and 4 deletions
|
@ -327,8 +327,10 @@ SCENARIO("Component Definition Properties")
|
|||
using namespace slint;
|
||||
|
||||
ComponentCompiler compiler;
|
||||
auto comp_def = *compiler.build_from_source(
|
||||
"export component Dummy { in property <string> test; callback dummy; }", "");
|
||||
auto comp_def =
|
||||
*compiler.build_from_source("export component Dummy { in property <string> test; "
|
||||
"callback dummy; public function my-fun() {} }",
|
||||
"");
|
||||
auto properties = comp_def.properties();
|
||||
REQUIRE(properties.size() == 1);
|
||||
REQUIRE(properties[0].property_name == "test");
|
||||
|
@ -338,6 +340,10 @@ SCENARIO("Component Definition Properties")
|
|||
REQUIRE(callback_names.size() == 1);
|
||||
REQUIRE(callback_names[0] == "dummy");
|
||||
|
||||
auto function_names = comp_def.functions();
|
||||
REQUIRE(function_names.size() == 1);
|
||||
REQUIRE(function_names[0] == "my-fun");
|
||||
|
||||
auto instance = comp_def.create();
|
||||
ComponentDefinition new_comp_def = instance->definition();
|
||||
auto new_props = new_comp_def.properties();
|
||||
|
@ -551,6 +557,10 @@ SCENARIO("Global properties")
|
|||
auto callbacks = *component_definition.global_callbacks("The-Global");
|
||||
REQUIRE(callbacks.size() == 1);
|
||||
REQUIRE(callbacks[0] == "to_uppercase");
|
||||
|
||||
auto functions = *component_definition.global_functions("The-Global");
|
||||
REQUIRE(functions.size() == 1);
|
||||
REQUIRE(functions[0] == "ff");
|
||||
}
|
||||
|
||||
auto instance = component_definition.create();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue