| 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 TestCase inherits Window { |
| 5 | out property<int> t1: round(42.2); |
| 6 | out property<int> t2: round(23.5); |
| 7 | out property<int> t3: round(24.6); |
| 8 | out property<int> t4: round(25); |
| 9 | |
| 10 | out property<int> n1: round(-42.2); |
| 11 | out property<int> n2: round(-23.5); |
| 12 | out property<int> n3: round(-24.6); |
| 13 | out property<int> n4: round(-25); |
| 14 | |
| 15 | out property <bool> test: 188.9.round() == 189 && (-4.58).round() == -(5.1).round(); |
| 16 | } |
| 17 | /* |
| 18 | ```cpp |
| 19 | auto handle = TestCase::create(); |
| 20 | const TestCase &instance = *handle; |
| 21 | assert_eq(instance.get_t1(), 42); |
| 22 | assert_eq(instance.get_t2(), 24); |
| 23 | assert_eq(instance.get_t3(), 25); |
| 24 | assert_eq(instance.get_t4(), 25); |
| 25 | assert_eq(instance.get_n1(), -42); |
| 26 | assert_eq(instance.get_n2(), -24); |
| 27 | assert_eq(instance.get_n3(), -25); |
| 28 | assert_eq(instance.get_n4(), -25); |
| 29 | assert(instance.get_test()); |
| 30 | ``` |
| 31 | |
| 32 | ```rust |
| 33 | let instance = TestCase::new().unwrap(); |
| 34 | assert_eq!(instance.get_t1(), 42); |
| 35 | assert_eq!(instance.get_t2(), 24); |
| 36 | assert_eq!(instance.get_t3(), 25); |
| 37 | assert_eq!(instance.get_t4(), 25); |
| 38 | assert_eq!(instance.get_n1(), -42); |
| 39 | assert_eq!(instance.get_n2(), -24); |
| 40 | assert_eq!(instance.get_n3(), -25); |
| 41 | assert_eq!(instance.get_n4(), -25); |
| 42 | assert!(instance.get_test()); |
| 43 | ``` |
| 44 | |
| 45 | ```js |
| 46 | var instance = new slint.TestCase({}); |
| 47 | assert.equal(instance.t1, 42); |
| 48 | assert.equal(instance.t2, 24); |
| 49 | assert.equal(instance.t3, 25); |
| 50 | assert.equal(instance.t4, 25); |
| 51 | assert.equal(instance.n1, -42); |
| 52 | assert.equal(instance.n2, -24); |
| 53 | assert.equal(instance.n3, -25); |
| 54 | assert.equal(instance.n4, -25); |
| 55 | assert(instance.test); |
| 56 | ``` |
| 57 | */ |
| 58 | |