1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
2 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
3 | |
4 | // Test that structs work if they are only referenced by functions |
5 | |
6 | struct Foo1 { member: int, } |
7 | struct Foo2 { a: Foo1 } |
8 | struct Foo3 { b: int } |
9 | |
10 | TestCase := TouchArea { |
11 | // Based on Issue #2655 |
12 | public function fn1(foo2: Foo2) -> Foo3 { |
13 | return { b: foo2.a.member+1 }; |
14 | } |
15 | } |
16 | |
17 | |
18 | /* |
19 | ```rust |
20 | let instance = TestCase::new().unwrap(); |
21 | |
22 | assert_eq!(instance.invoke_fn1(Foo2{ a: Foo1{ member: 123 } }).b, 124); |
23 | ``` |
24 | |
25 | ```cpp |
26 | auto handle = TestCase::create(); |
27 | const TestCase &instance = *handle; |
28 | |
29 | assert_eq(instance.invoke_fn1(Foo2{ Foo1{ 123 } }).b, 124); |
30 | ``` |
31 | |
32 | */ |
33 | |