mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-27 12:29:41 +00:00
Use the new syntax in more tests
That are failing otherwise as there would be a warning
This commit is contained in:
parent
6f3dfc992f
commit
e57627d535
4 changed files with 43 additions and 43 deletions
|
@ -292,7 +292,7 @@ SCENARIO("Component Compiler")
|
||||||
|
|
||||||
SECTION("Compile from source")
|
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());
|
REQUIRE(result.has_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +320,7 @@ SCENARIO("Component Definition Properties")
|
||||||
|
|
||||||
ComponentCompiler compiler;
|
ComponentCompiler compiler;
|
||||||
auto comp_def = *compiler.build_from_source(
|
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();
|
auto properties = comp_def.properties();
|
||||||
REQUIRE(properties.size() == 1);
|
REQUIRE(properties.size() == 1);
|
||||||
REQUIRE(properties[0].property_name == "test");
|
REQUIRE(properties[0].property_name == "test");
|
||||||
|
@ -338,7 +338,7 @@ SCENARIO("Component Definition Properties / Two-way bindings")
|
||||||
|
|
||||||
ComponentCompiler compiler;
|
ComponentCompiler compiler;
|
||||||
auto comp_def = *compiler.build_from_source(
|
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; }"
|
" sub_object := Rectangle { property <string> test; }"
|
||||||
"}",
|
"}",
|
||||||
"");
|
"");
|
||||||
|
@ -358,7 +358,7 @@ SCENARIO("Invoke callback")
|
||||||
SECTION("valid")
|
SECTION("valid")
|
||||||
{
|
{
|
||||||
auto result = compiler.build_from_source(
|
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());
|
REQUIRE(result.has_value());
|
||||||
auto instance = result->create();
|
auto instance = result->create();
|
||||||
std::string local_string = "_string_on_the_stack_";
|
std::string local_string = "_string_on_the_stack_";
|
||||||
|
@ -377,7 +377,7 @@ SCENARIO("Invoke callback")
|
||||||
SECTION("invalid")
|
SECTION("invalid")
|
||||||
{
|
{
|
||||||
auto result = compiler.build_from_source(
|
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());
|
REQUIRE(result.has_value());
|
||||||
auto instance = result->create();
|
auto instance = result->create();
|
||||||
REQUIRE(!instance->set_callback("bar", [](auto) { return Value(); }));
|
REQUIRE(!instance->set_callback("bar", [](auto) { return Value(); }));
|
||||||
|
@ -395,7 +395,7 @@ SCENARIO("Array between .slint and C++")
|
||||||
ComponentCompiler compiler;
|
ComponentCompiler compiler;
|
||||||
|
|
||||||
auto result = compiler.build_from_source(
|
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());
|
REQUIRE(result.has_value());
|
||||||
auto instance = result->create();
|
auto instance = result->create();
|
||||||
|
|
||||||
|
@ -430,10 +430,10 @@ SCENARIO("Angle between .slint and C++")
|
||||||
|
|
||||||
ComponentCompiler compiler;
|
ComponentCompiler compiler;
|
||||||
|
|
||||||
auto result =
|
auto result = compiler.build_from_source(
|
||||||
compiler.build_from_source("export Dummy := Rectangle { property <angle> the_angle: "
|
"export component Dummy { in-out property <angle> the_angle: "
|
||||||
"0.25turn; property <bool> test: the_angle == 0.5turn; }",
|
"0.25turn; out property <bool> test: the_angle == 0.5turn; }",
|
||||||
"");
|
"");
|
||||||
REQUIRE(result.has_value());
|
REQUIRE(result.has_value());
|
||||||
auto instance = result->create();
|
auto instance = result->create();
|
||||||
|
|
||||||
|
@ -462,7 +462,7 @@ SCENARIO("Component Definition Name")
|
||||||
using namespace slint;
|
using namespace slint;
|
||||||
|
|
||||||
ComponentCompiler compiler;
|
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");
|
REQUIRE(comp_def.name() == "IHaveAName");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,9 +473,9 @@ SCENARIO("Send key events")
|
||||||
|
|
||||||
ComponentCompiler compiler;
|
ComponentCompiler compiler;
|
||||||
auto comp_def = compiler.build_from_source(R"(
|
auto comp_def = compiler.build_from_source(R"(
|
||||||
export Dummy := Rectangle {
|
export component Dummy {
|
||||||
forward-focus: scope;
|
forward-focus: scope;
|
||||||
property <string> result;
|
out property <string> result;
|
||||||
scope := FocusScope {
|
scope := FocusScope {
|
||||||
key-pressed(event) => {
|
key-pressed(event) => {
|
||||||
if (event.text != Key.Shift && event.text != Key.Control) {
|
if (event.text != Key.Shift && event.text != Key.Control) {
|
||||||
|
@ -502,13 +502,13 @@ SCENARIO("Global properties")
|
||||||
|
|
||||||
auto result = compiler.build_from_source(
|
auto result = compiler.build_from_source(
|
||||||
R"(
|
R"(
|
||||||
export global The-Global := {
|
export global The-Global {
|
||||||
property <string> the-property: "€€€";
|
in-out property <string> the-property: "€€€";
|
||||||
callback to_uppercase(string)->string;
|
pure callback to_uppercase(string)->string;
|
||||||
public function ff() -> string { return the-property; }
|
public function ff() -> string { return the-property; }
|
||||||
}
|
}
|
||||||
export Dummy := Rectangle {
|
export component Dummy {
|
||||||
property <string> result: The-Global.to_uppercase("abc");
|
out property <string> result: The-Global.to_uppercase("abc");
|
||||||
}
|
}
|
||||||
)",
|
)",
|
||||||
"");
|
"");
|
||||||
|
|
|
@ -758,8 +758,8 @@ impl ComponentInstance {
|
||||||
/// ```
|
/// ```
|
||||||
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
|
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
|
||||||
/// let code = r#"
|
/// let code = r#"
|
||||||
/// export MyWin := Window {
|
/// export component MyWin inherits Window {
|
||||||
/// property <int> my_property: 42;
|
/// in-out property <int> my_property: 42;
|
||||||
/// }
|
/// }
|
||||||
/// "#;
|
/// "#;
|
||||||
/// let mut compiler = ComponentCompiler::default();
|
/// let mut compiler = ComponentCompiler::default();
|
||||||
|
@ -825,9 +825,9 @@ impl ComponentInstance {
|
||||||
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString, ComponentHandle};
|
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString, ComponentHandle};
|
||||||
/// use core::convert::TryInto;
|
/// use core::convert::TryInto;
|
||||||
/// let code = r#"
|
/// let code = r#"
|
||||||
/// MyWin := Window {
|
/// component MyWin inherits Window {
|
||||||
/// callback foo(int) -> int;
|
/// callback foo(int) -> int;
|
||||||
/// property <int> my_prop: 12;
|
/// in-out property <int> my_prop: 12;
|
||||||
/// }
|
/// }
|
||||||
/// "#;
|
/// "#;
|
||||||
/// let definition = spin_on::spin_on(
|
/// let definition = spin_on::spin_on(
|
||||||
|
@ -879,11 +879,11 @@ impl ComponentInstance {
|
||||||
/// ```
|
/// ```
|
||||||
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
|
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
|
||||||
/// let code = r#"
|
/// let code = r#"
|
||||||
/// global Glob := {
|
/// global Glob {
|
||||||
/// property <int> my_property: 42;
|
/// in-out property <int> my_property: 42;
|
||||||
/// }
|
/// }
|
||||||
/// export { Glob as TheGlobal }
|
/// export { Glob as TheGlobal }
|
||||||
/// MyWin := Window {
|
/// component MyWin inherits Window {
|
||||||
/// }
|
/// }
|
||||||
/// "#;
|
/// "#;
|
||||||
/// let mut compiler = ComponentCompiler::default();
|
/// let mut compiler = ComponentCompiler::default();
|
||||||
|
@ -934,11 +934,11 @@ impl ComponentInstance {
|
||||||
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
|
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
|
||||||
/// use core::convert::TryInto;
|
/// use core::convert::TryInto;
|
||||||
/// let code = r#"
|
/// let code = r#"
|
||||||
/// export global Logic := {
|
/// export global Logic {
|
||||||
/// callback to_uppercase(string) -> string;
|
/// pure callback to_uppercase(string) -> string;
|
||||||
/// }
|
/// }
|
||||||
/// MyWin := Window {
|
/// component MyWin inherits Window {
|
||||||
/// property <string> hello: Logic.to_uppercase("world");
|
/// out property <string> hello: Logic.to_uppercase("world");
|
||||||
/// }
|
/// }
|
||||||
/// "#;
|
/// "#;
|
||||||
/// let definition = spin_on::spin_on(
|
/// let definition = spin_on::spin_on(
|
||||||
|
@ -1173,9 +1173,9 @@ fn component_definition_properties() {
|
||||||
let comp_def = spin_on::spin_on(
|
let comp_def = spin_on::spin_on(
|
||||||
compiler.build_from_source(
|
compiler.build_from_source(
|
||||||
r#"
|
r#"
|
||||||
export Dummy := Rectangle {
|
export component Dummy {
|
||||||
property <string> test;
|
in-out property <string> test;
|
||||||
property <int> underscores-and-dashes_preserved: 44;
|
in-out property <int> underscores-and-dashes_preserved: 44;
|
||||||
callback hello;
|
callback hello;
|
||||||
}"#
|
}"#
|
||||||
.into(),
|
.into(),
|
||||||
|
@ -1221,8 +1221,8 @@ fn component_definition_properties2() {
|
||||||
let comp_def = spin_on::spin_on(
|
let comp_def = spin_on::spin_on(
|
||||||
compiler.build_from_source(
|
compiler.build_from_source(
|
||||||
r#"
|
r#"
|
||||||
export Dummy := Rectangle {
|
export component Dummy {
|
||||||
property <string> sub-text <=> sub.text;
|
in-out property <string> sub-text <=> sub.text;
|
||||||
sub := Text { property <int> private-not-exported; }
|
sub := Text { property <int> private-not-exported; }
|
||||||
out property <string> xreadonly: "the value";
|
out property <string> xreadonly: "the value";
|
||||||
private property <string> xx: sub.text;
|
private property <string> xx: sub.text;
|
||||||
|
@ -1272,12 +1272,12 @@ fn globals() {
|
||||||
let definition = spin_on::spin_on(
|
let definition = spin_on::spin_on(
|
||||||
compiler.build_from_source(
|
compiler.build_from_source(
|
||||||
r#"
|
r#"
|
||||||
export global My-Super_Global := {
|
export global My-Super_Global {
|
||||||
property <int> the-property : 21;
|
in-out property <int> the-property : 21;
|
||||||
callback my-callback();
|
callback my-callback();
|
||||||
}
|
}
|
||||||
export { My-Super_Global as AliasedGlobal }
|
export { My-Super_Global as AliasedGlobal }
|
||||||
export Dummy := Rectangle {
|
export component Dummy {
|
||||||
}"#
|
}"#
|
||||||
.into(),
|
.into(),
|
||||||
"".into(),
|
"".into(),
|
||||||
|
|
|
@ -43,8 +43,8 @@ This example load a `.slint` from a string and set some properties:
|
||||||
use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString, ComponentHandle};
|
use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString, ComponentHandle};
|
||||||
|
|
||||||
let code = r#"
|
let code = r#"
|
||||||
export MyWin := Window {
|
export component MyWin inherits Window {
|
||||||
property <string> my_name;
|
in property <string> my_name;
|
||||||
Text {
|
Text {
|
||||||
text: "Hello, " + my_name;
|
text: "Hello, " + my_name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,11 @@ fn reuse_window() {
|
||||||
i_slint_backend_testing::init();
|
i_slint_backend_testing::init();
|
||||||
use crate::{ComponentCompiler, ComponentHandle, SharedString, Value};
|
use crate::{ComponentCompiler, ComponentHandle, SharedString, Value};
|
||||||
let code = r#"
|
let code = r#"
|
||||||
export MainWindow := Window {
|
export component MainWindow inherits Window {
|
||||||
property<string> text_text: "foo";
|
in-out property<string> text_text: "foo";
|
||||||
property<string> text_alias: input.text;
|
in-out property<string> text_alias: input.text;
|
||||||
input := TextInput {
|
input := TextInput {
|
||||||
text: enabled ? text_text : text_text;
|
text: self.enabled ? text_text : text_text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"#;
|
"#;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue