Use the new syntax in more tests

That are failing otherwise as there would be a warning
This commit is contained in:
Olivier Goffart 2023-02-10 16:15:03 +01:00 committed by Olivier Goffart
parent 6f3dfc992f
commit e57627d535
4 changed files with 43 additions and 43 deletions

View file

@ -292,7 +292,7 @@ SCENARIO("Component Compiler")
SECTION("Compile from source")
{
auto result = compiler.build_from_source("export Dummy := Rectangle {}", "");
auto result = compiler.build_from_source("export component Dummy {}", "");
REQUIRE(result.has_value());
}
@ -320,7 +320,7 @@ SCENARIO("Component Definition Properties")
ComponentCompiler compiler;
auto comp_def = *compiler.build_from_source(
"export Dummy := Rectangle { property <string> test; callback dummy; }", "");
"export component Dummy { in property <string> test; callback dummy; }", "");
auto properties = comp_def.properties();
REQUIRE(properties.size() == 1);
REQUIRE(properties[0].property_name == "test");
@ -338,7 +338,7 @@ SCENARIO("Component Definition Properties / Two-way bindings")
ComponentCompiler compiler;
auto comp_def = *compiler.build_from_source(
"export Dummy := Rectangle { property <string> test <=> sub_object.test; "
"export component Dummy { in-out property <string> test <=> sub_object.test; "
" sub_object := Rectangle { property <string> test; }"
"}",
"");
@ -358,7 +358,7 @@ SCENARIO("Invoke callback")
SECTION("valid")
{
auto result = compiler.build_from_source(
"export Dummy := Rectangle { callback some_callback(string, int) -> string; }", "");
"export component Dummy { callback some_callback(string, int) -> string; }", "");
REQUIRE(result.has_value());
auto instance = result->create();
std::string local_string = "_string_on_the_stack_";
@ -377,7 +377,7 @@ SCENARIO("Invoke callback")
SECTION("invalid")
{
auto result = compiler.build_from_source(
"export Dummy := Rectangle { callback foo(string, int) -> string; }", "");
"export component Dummy { callback foo(string, int) -> string; }", "");
REQUIRE(result.has_value());
auto instance = result->create();
REQUIRE(!instance->set_callback("bar", [](auto) { return Value(); }));
@ -395,7 +395,7 @@ SCENARIO("Array between .slint and C++")
ComponentCompiler compiler;
auto result = compiler.build_from_source(
"export Dummy := Rectangle { property <[int]> array: [1, 2, 3]; }", "");
"export component Dummy { in-out property <[int]> array: [1, 2, 3]; }", "");
REQUIRE(result.has_value());
auto instance = result->create();
@ -430,10 +430,10 @@ SCENARIO("Angle between .slint and C++")
ComponentCompiler compiler;
auto result =
compiler.build_from_source("export Dummy := Rectangle { property <angle> the_angle: "
"0.25turn; property <bool> test: the_angle == 0.5turn; }",
"");
auto result = compiler.build_from_source(
"export component Dummy { in-out property <angle> the_angle: "
"0.25turn; out property <bool> test: the_angle == 0.5turn; }",
"");
REQUIRE(result.has_value());
auto instance = result->create();
@ -462,7 +462,7 @@ SCENARIO("Component Definition Name")
using namespace slint;
ComponentCompiler compiler;
auto comp_def = *compiler.build_from_source("export IHaveAName := Rectangle { }", "");
auto comp_def = *compiler.build_from_source("export component IHaveAName { }", "");
REQUIRE(comp_def.name() == "IHaveAName");
}
@ -473,9 +473,9 @@ SCENARIO("Send key events")
ComponentCompiler compiler;
auto comp_def = compiler.build_from_source(R"(
export Dummy := Rectangle {
export component Dummy {
forward-focus: scope;
property <string> result;
out property <string> result;
scope := FocusScope {
key-pressed(event) => {
if (event.text != Key.Shift && event.text != Key.Control) {
@ -502,13 +502,13 @@ SCENARIO("Global properties")
auto result = compiler.build_from_source(
R"(
export global The-Global := {
property <string> the-property: "€€€";
callback to_uppercase(string)->string;
export global The-Global {
in-out property <string> the-property: "€€€";
pure callback to_uppercase(string)->string;
public function ff() -> string { return the-property; }
}
export Dummy := Rectangle {
property <string> result: The-Global.to_uppercase("abc");
export component Dummy {
out property <string> result: The-Global.to_uppercase("abc");
}
)",
"");

View file

@ -758,8 +758,8 @@ impl ComponentInstance {
/// ```
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
/// let code = r#"
/// export MyWin := Window {
/// property <int> my_property: 42;
/// export component MyWin inherits Window {
/// in-out property <int> my_property: 42;
/// }
/// "#;
/// let mut compiler = ComponentCompiler::default();
@ -825,9 +825,9 @@ impl ComponentInstance {
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString, ComponentHandle};
/// use core::convert::TryInto;
/// let code = r#"
/// MyWin := Window {
/// component MyWin inherits Window {
/// callback foo(int) -> int;
/// property <int> my_prop: 12;
/// in-out property <int> my_prop: 12;
/// }
/// "#;
/// let definition = spin_on::spin_on(
@ -879,11 +879,11 @@ impl ComponentInstance {
/// ```
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
/// let code = r#"
/// global Glob := {
/// property <int> my_property: 42;
/// global Glob {
/// in-out property <int> my_property: 42;
/// }
/// export { Glob as TheGlobal }
/// MyWin := Window {
/// component MyWin inherits Window {
/// }
/// "#;
/// let mut compiler = ComponentCompiler::default();
@ -934,11 +934,11 @@ impl ComponentInstance {
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
/// use core::convert::TryInto;
/// let code = r#"
/// export global Logic := {
/// callback to_uppercase(string) -> string;
/// export global Logic {
/// pure callback to_uppercase(string) -> string;
/// }
/// MyWin := Window {
/// property <string> hello: Logic.to_uppercase("world");
/// component MyWin inherits Window {
/// out property <string> hello: Logic.to_uppercase("world");
/// }
/// "#;
/// let definition = spin_on::spin_on(
@ -1173,9 +1173,9 @@ fn component_definition_properties() {
let comp_def = spin_on::spin_on(
compiler.build_from_source(
r#"
export Dummy := Rectangle {
property <string> test;
property <int> underscores-and-dashes_preserved: 44;
export component Dummy {
in-out property <string> test;
in-out property <int> underscores-and-dashes_preserved: 44;
callback hello;
}"#
.into(),
@ -1221,8 +1221,8 @@ fn component_definition_properties2() {
let comp_def = spin_on::spin_on(
compiler.build_from_source(
r#"
export Dummy := Rectangle {
property <string> sub-text <=> sub.text;
export component Dummy {
in-out property <string> sub-text <=> sub.text;
sub := Text { property <int> private-not-exported; }
out property <string> xreadonly: "the value";
private property <string> xx: sub.text;
@ -1272,12 +1272,12 @@ fn globals() {
let definition = spin_on::spin_on(
compiler.build_from_source(
r#"
export global My-Super_Global := {
property <int> the-property : 21;
export global My-Super_Global {
in-out property <int> the-property : 21;
callback my-callback();
}
export { My-Super_Global as AliasedGlobal }
export Dummy := Rectangle {
export component Dummy {
}"#
.into(),
"".into(),

View file

@ -43,8 +43,8 @@ This example load a `.slint` from a string and set some properties:
use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString, ComponentHandle};
let code = r#"
export MyWin := Window {
property <string> my_name;
export component MyWin inherits Window {
in property <string> my_name;
Text {
text: "Hello, " + my_name;
}

View file

@ -6,11 +6,11 @@ fn reuse_window() {
i_slint_backend_testing::init();
use crate::{ComponentCompiler, ComponentHandle, SharedString, Value};
let code = r#"
export MainWindow := Window {
property<string> text_text: "foo";
property<string> text_alias: input.text;
export component MainWindow inherits Window {
in-out property<string> text_text: "foo";
in-out property<string> text_alias: input.text;
input := TextInput {
text: enabled ? text_text : text_text;
text: self.enabled ? text_text : text_text;
}
}
"#;