mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
Test for angle in the C++ interpreter API
This commit is contained in:
parent
be37a9f69a
commit
9ffcd34d1b
1 changed files with 31 additions and 0 deletions
|
@ -426,6 +426,37 @@ SCENARIO("Array between .60 and C++")
|
|||
}
|
||||
}
|
||||
|
||||
SCENARIO("Angle between .60 and C++")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
using namespace sixtyfps;
|
||||
|
||||
ComponentCompiler compiler;
|
||||
|
||||
auto result = compiler.build_from_source(
|
||||
"export Dummy := Rectangle { property <angle> angle: 0.25turn; property <bool> test: angle == 0.5turn; }", "");
|
||||
REQUIRE(result.has_value());
|
||||
auto instance = result->create();
|
||||
|
||||
SECTION("Read property")
|
||||
{
|
||||
auto angle_value = instance->get_property("angle");
|
||||
REQUIRE(angle_value.has_value());
|
||||
REQUIRE(angle_value->type() == Value::Type::Number);
|
||||
auto angle = angle_value->to_number();
|
||||
REQUIRE(angle.has_value());
|
||||
REQUIRE(*angle == 90);
|
||||
}
|
||||
SECTION("Write property")
|
||||
{
|
||||
REQUIRE(!*instance->get_property("test")->to_bool());
|
||||
bool ok = instance->set_property("angle", 180.);
|
||||
REQUIRE(ok);
|
||||
REQUIRE(*instance->get_property("angle")->to_number() == 180);
|
||||
REQUIRE(*instance->get_property("test")->to_bool());
|
||||
}
|
||||
}
|
||||
|
||||
SCENARIO("Component Definition Name")
|
||||
{
|
||||
using namespace sixtyfps::interpreter;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue