| 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 | export component TestCase { |
| 5 | |
| 6 | property <float> float-var: 26.7; |
| 7 | // Going through a private property of type int should really cast to int |
| 8 | private property <int> tens-digit-var: float-var / 10; |
| 9 | |
| 10 | // test that it rounds |
| 11 | out property <int> int-val: -7.6; |
| 12 | |
| 13 | out property <string> text: tens-digit-var; |
| 14 | out property <bool> test: tens-digit-var == 2 && text == "2" && int-val == -7; |
| 15 | } |
| 16 | |
| 17 | |
| 18 | /* |
| 19 | |
| 20 | ```cpp |
| 21 | auto handle = TestCase::create(); |
| 22 | const TestCase &instance = *handle; |
| 23 | assert_eq(instance.get_text(), "2"); |
| 24 | assert_eq(instance.get_int_val(), -7); |
| 25 | assert(instance.get_test()); |
| 26 | ``` |
| 27 | |
| 28 | ```rust |
| 29 | let instance = TestCase::new().unwrap(); |
| 30 | assert_eq!(instance.get_text(), "2"); |
| 31 | assert_eq!(instance.get_int_val(), -7); |
| 32 | assert!(instance.get_test()); |
| 33 | ``` |
| 34 | |
| 35 | ```js |
| 36 | var instance = new slint.TestCase({}); |
| 37 | assert.equal(instance.text, "2"); |
| 38 | assert.equal(instance.int_val, -7); |
| 39 | assert(instance.test); |
| 40 | ``` |
| 41 | |
| 42 | */ |
| 43 | |