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 | export component TestCase { |
6 | in property <float> value: 42.0; |
7 | out property <float> t1: clamp(value, 10.0, 53.0); |
8 | out property <float> t2: clamp(value, 43.0, 53.0); |
9 | out property <float> t3: clamp(value, 10.0, 41.0); |
10 | |
11 | r := Rectangle { |
12 | property <int> max: 42; |
13 | property <int> xx: Math.clamp(5, 2, 3) + max; |
14 | } |
15 | out property <bool> test: root.t1 == 42.0 && root.t2 == 43.0 && root.t3 == 41.0 && r.xx == 42 + 3; |
16 | } |
17 | /* |
18 | ```cpp |
19 | auto handle = TestCase::create(); |
20 | const TestCase &instance = *handle; |
21 | assert_eq(instance.get_t1(), 42.0); |
22 | assert_eq(instance.get_t2(), 43.0); |
23 | assert_eq(instance.get_t3(), 41.0); |
24 | assert_eq(instance.get_test(), true); |
25 | ``` |
26 | |
27 | |
28 | ```rust |
29 | let instance = TestCase::new().unwrap(); |
30 | assert_eq!(instance.get_t1(), 42.0); |
31 | assert_eq!(instance.get_t2(), 43.0); |
32 | assert_eq!(instance.get_t3(), 41.0); |
33 | assert_eq!(instance.get_test(), true); |
34 | ``` |
35 | |
36 | ```js |
37 | var instance = new slint.TestCase({}); |
38 | assert.equal(instance.t1, 42.0); |
39 | assert.equal(instance.t2, 43.0); |
40 | assert.equal(instance.t3, 41.0); |
41 | assert(instance.test); |
42 | ``` |
43 | */ |
44 | } |
45 | |
46 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
47 | use i_slint_backend_testing as slint_testing; |
48 | slint_testing::init(); |
49 | let instance = TestCase::new().unwrap(); |
50 | assert_eq!(instance.get_t1(), 42.0); |
51 | assert_eq!(instance.get_t2(), 43.0); |
52 | assert_eq!(instance.get_t3(), 41.0); |
53 | assert_eq!(instance.get_test(), true); |
54 | Ok(()) |
55 | } |