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
5export 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
19auto handle = TestCase::create();
20const TestCase &instance = *handle;
21assert_eq(instance.get_t1(), 42.0);
22assert_eq(instance.get_t2(), 43.0);
23assert_eq(instance.get_t3(), 41.0);
24assert_eq(instance.get_test(), true);
25```
26
27
28```rust
29let instance = TestCase::new().unwrap();
30assert_eq!(instance.get_t1(), 42.0);
31assert_eq!(instance.get_t2(), 43.0);
32assert_eq!(instance.get_t3(), 41.0);
33assert_eq!(instance.get_test(), true);
34```
35
36```js
37var instance = new slint.TestCase({});
38assert.equal(instance.t1, 42.0);
39assert.equal(instance.t2, 43.0);
40assert.equal(instance.t3, 41.0);
41assert(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}