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
4global G := {
5 property <string> hello: "hello";
6 function meh(w: string) -> string {
7 return hello + " " + w;
8 }
9}
10
11SubCompo := Rectangle {
12 public pure function hello() -> color { red }
13}
14
15export global PubGlob := {
16 public function beh(a: int, b: int) -> int { a + b + 10 }
17}
18
19TestCase := Rectangle {
20
21 property <int> c: 100000;
22 private property <int> one: 1 + Math.round((x / 1px) - (y / 1px));
23
24 function foo() {}
25 function the_function(a: int, b: int) -> int { foo(); a + b + c + one }
26
27 if true : Rectangle {
28 background: the_function(1, 2) > 3 ? blue: sc.hello();
29 }
30
31 sc := SubCompo {
32
33 }
34
35 public function pub(a: int, b: int) -> int { a + b + c }
36
37 public function set_c(p: int) { c = p }
38
39
40 property <bool> test: the_function(4500, 20) == 104521 && G.meh("world") == "hello world" && sc.hello() == Colors.red;
41}
42
43/*
44```rust
45let instance = TestCase::new().unwrap();
46assert!(instance.get_test());
47assert_eq!(instance.invoke_pub(20, 2), 100022);
48assert_eq!(instance.global::<PubGlob<'_>>().invoke_beh(2, 2), 14);
49```
50
51```cpp
52auto handle = TestCase::create();
53const TestCase &instance = *handle;
54assert(instance.get_test());
55assert_eq(instance.invoke_pub(20, 2), 100022);
56assert_eq(instance.global<PubGlob>().invoke_beh(2, 2), 14);
57```
58
59
60```js
61var instance = new slint.TestCase();
62assert(instance.test);
63assert.equal(instance.pub(20, 2), 100022);
64assert.equal(instance.PubGlob.beh(2, 2), 14);
65```
66*/
67