| 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 | |
| 5 | export global G { |
| 6 | in-out property <int> dummy; |
| 7 | |
| 8 | callback do-something(val: string); |
| 9 | do-something(val) => { |
| 10 | result += val; |
| 11 | } |
| 12 | callback do-something-else() -> bool; |
| 13 | in-out property <string> result; |
| 14 | } |
| 15 | |
| 16 | export component TestCase inherits Window { |
| 17 | |
| 18 | callback cal1(); |
| 19 | cal1 => { |
| 20 | if G.dummy == 0 { |
| 21 | G.do-something("cal" ); |
| 22 | } else { |
| 23 | G.do-something-else(); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | callback cal2() -> int; |
| 28 | cal2 => { |
| 29 | if G.dummy == 1 { |
| 30 | G.do-something("***" ); |
| 31 | } else if G.dummy == 2 { |
| 32 | G.do-something-else(); |
| 33 | } else { |
| 34 | return 1; |
| 35 | } |
| 36 | |
| 37 | 2 |
| 38 | } |
| 39 | |
| 40 | init => { |
| 41 | cal1(); |
| 42 | G.result += cal2(); |
| 43 | } |
| 44 | in-out property <bool> test: G.result == "cal1" ; |
| 45 | } |
| 46 | |
| 47 | /* |
| 48 | ```cpp |
| 49 | auto handle = TestCase::create(); |
| 50 | const TestCase &instance = *handle; |
| 51 | assert(instance.get_test()); |
| 52 | ``` |
| 53 | |
| 54 | ```rust |
| 55 | let instance = TestCase::new().unwrap(); |
| 56 | assert!(instance.get_test()); |
| 57 | ``` |
| 58 | */ |
| 59 | |
| 60 | |
| 61 | |