1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/types"# ] |
2 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
3 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
4 | |
5 | // Test that structs work if they are only referenced by functions |
6 | |
7 | struct Foo1 { member: int, } |
8 | struct Foo2 { a: Foo1 } |
9 | struct Foo3 { b: int } |
10 | |
11 | TestCase := TouchArea { |
12 | // Based on Issue #2655 |
13 | public function fn1(foo2: Foo2) -> Foo3 { |
14 | return { b: foo2.a.member+1 }; |
15 | } |
16 | } |
17 | |
18 | |
19 | /* |
20 | ```rust |
21 | let instance = TestCase::new().unwrap(); |
22 | |
23 | assert_eq!(instance.invoke_fn1(Foo2{ a: Foo1{ member: 123 } }).b, 124); |
24 | ``` |
25 | |
26 | ```cpp |
27 | auto handle = TestCase::create(); |
28 | const TestCase &instance = *handle; |
29 | |
30 | assert_eq(instance.invoke_fn1(Foo2{ Foo1{ 123 } }).b, 124); |
31 | ``` |
32 | |
33 | */ |
34 | } |
35 | |
36 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
37 | use i_slint_backend_testing as slint_testing; |
38 | slint_testing::init(); |
39 | let instance = TestCase::new().unwrap(); |
40 | |
41 | assert_eq!(instance.invoke_fn1(Foo2{ a: Foo1{ member: 123 } }).b, 124); |
42 | Ok(()) |
43 | } |