mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
Clarify model handling in C++ interpreter slightly
* Remove `Value::to_model()` as it is not implemented * Document that models can be passed to .60 array/object properties * Add a test for the extraction / setting behavior of arrays.
This commit is contained in:
parent
b875a19310
commit
25a1e666d9
2 changed files with 42 additions and 4 deletions
|
@ -337,3 +337,39 @@ SCENARIO("Invoke callback")
|
|||
REQUIRE(!res.has_value());
|
||||
}
|
||||
}
|
||||
|
||||
SCENARIO("Array between .60 and C++")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace sixtyfps;
|
||||
|
||||
ComponentCompiler compiler;
|
||||
|
||||
auto result = compiler.build_from_source(
|
||||
"export Dummy := Rectangle { property <[int]> array: [1, 2, 3]; }", "");
|
||||
REQUIRE(result.has_value());
|
||||
auto instance = result->create();
|
||||
|
||||
SECTION(".60 to C++")
|
||||
{
|
||||
auto maybe_array = instance->get_property("array");
|
||||
REQUIRE(maybe_array.has_value());
|
||||
REQUIRE(maybe_array->type() == Value::Type::Array);
|
||||
|
||||
auto array = *maybe_array;
|
||||
REQUIRE(array == sixtyfps::SharedVector<Value> { Value(1.), Value(2.), Value(3.) });
|
||||
}
|
||||
|
||||
SECTION("C++ to .60")
|
||||
{
|
||||
sixtyfps::SharedVector<Value> cpp_array { Value(4.), Value(5.), Value(6.) };
|
||||
|
||||
instance->set_property("array", Value(cpp_array));
|
||||
auto maybe_array = instance->get_property("array");
|
||||
REQUIRE(maybe_array.has_value());
|
||||
REQUIRE(maybe_array->type() == Value::Type::Array);
|
||||
|
||||
auto actual_array = *maybe_array;
|
||||
REQUIRE(actual_array == cpp_array);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue