1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/expr"# ] |
2 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
3 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
4 | |
5 | TestCase := Rectangle { |
6 | property<int> t1: ceil(42.2); |
7 | property<int> t2: ceil(23.5); |
8 | property<int> t3: ceil(24.6); |
9 | property<int> t4: ceil(25); |
10 | |
11 | property<int> n1: ceil(-42.2); |
12 | property<int> n2: ceil(-23.5); |
13 | property<int> n3: ceil(-24.6); |
14 | property<int> n4: ceil(-25); |
15 | } |
16 | /* |
17 | ```cpp |
18 | auto handle = TestCase::create(); |
19 | const TestCase &instance = *handle; |
20 | assert_eq(instance.get_t1(), 43); |
21 | assert_eq(instance.get_t2(), 24); |
22 | assert_eq(instance.get_t3(), 25); |
23 | assert_eq(instance.get_t4(), 25); |
24 | assert_eq(instance.get_n1(), -42); |
25 | assert_eq(instance.get_n2(), -23); |
26 | assert_eq(instance.get_n3(), -24); |
27 | assert_eq(instance.get_n4(), -25); |
28 | ``` |
29 | |
30 | ```rust |
31 | let instance = TestCase::new().unwrap(); |
32 | assert_eq!(instance.get_t1(), 43); |
33 | assert_eq!(instance.get_t2(), 24); |
34 | assert_eq!(instance.get_t3(), 25); |
35 | assert_eq!(instance.get_t4(), 25); |
36 | assert_eq!(instance.get_n1(), -42); |
37 | assert_eq!(instance.get_n2(), -23); |
38 | assert_eq!(instance.get_n3(), -24); |
39 | assert_eq!(instance.get_n4(), -25); |
40 | ``` |
41 | |
42 | ```js |
43 | var instance = new slint.TestCase({}); |
44 | assert.equal(instance.t1, 43); |
45 | assert.equal(instance.t2, 24); |
46 | assert.equal(instance.t3, 25); |
47 | assert.equal(instance.t4, 25); |
48 | assert.equal(instance.n1, -42); |
49 | assert.equal(instance.n2, -23); |
50 | assert.equal(instance.n3, -24); |
51 | assert.equal(instance.n4, -25); |
52 | ``` |
53 | */ |
54 | } |
55 | |
56 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
57 | use i_slint_backend_testing as slint_testing; |
58 | slint_testing::init(); |
59 | let instance = TestCase::new().unwrap(); |
60 | assert_eq!(instance.get_t1(), 43); |
61 | assert_eq!(instance.get_t2(), 24); |
62 | assert_eq!(instance.get_t3(), 25); |
63 | assert_eq!(instance.get_t4(), 25); |
64 | assert_eq!(instance.get_n1(), -42); |
65 | assert_eq!(instance.get_n2(), -23); |
66 | assert_eq!(instance.get_n3(), -24); |
67 | assert_eq!(instance.get_n4(), -25); |
68 | Ok(()) |
69 | } |