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