| 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 | component IndirectChange { |
| 5 | in property <[int]> mod; |
| 6 | property <[int]> private: mod; |
| 7 | |
| 8 | init => { |
| 9 | private[0] += 1; |
| 10 | } |
| 11 | } |
| 12 | |
| 13 | export component TestCase { |
| 14 | |
| 15 | property <[int]> m1: [5]; |
| 16 | property <[int]> m2: [8]; |
| 17 | property <[int]> indirect: m2; |
| 18 | |
| 19 | public function up() { |
| 20 | indirect[0] += 10; |
| 21 | } |
| 22 | |
| 23 | callback up2(); |
| 24 | up2 => {up()} |
| 25 | |
| 26 | IndirectChange { mod: m1; } |
| 27 | |
| 28 | out property <int> t1: m1[0]; |
| 29 | out property <int> t2: m2[0]; |
| 30 | |
| 31 | out property <bool> test: t1 == 5+1 && t2 == 8; |
| 32 | } |
| 33 | |
| 34 | /* |
| 35 | ```cpp |
| 36 | auto handle = TestCase::create(); |
| 37 | const TestCase &instance = *handle; |
| 38 | assert_eq(instance.get_t1(), 6); |
| 39 | assert(instance.get_test()); |
| 40 | instance.invoke_up(); |
| 41 | assert_eq(instance.get_t2(), 18); |
| 42 | |
| 43 | ``` |
| 44 | |
| 45 | |
| 46 | ```rust |
| 47 | let instance = TestCase::new().unwrap(); |
| 48 | assert_eq!(instance.get_t1(), 6); |
| 49 | assert!(instance.get_test()); |
| 50 | instance.invoke_up(); |
| 51 | assert_eq!(instance.get_t2(), 18); |
| 52 | ``` |
| 53 | |
| 54 | ```js |
| 55 | var instance = new slint.TestCase({}); |
| 56 | assert.equal(instance.t1, 6); |
| 57 | assert(instance.test); |
| 58 | instance.up2(); |
| 59 | assert.equal(instance.t2, 18); |
| 60 | ``` |
| 61 | */ |
| 62 | |