1#![allow(deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/types"#]
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
5TestCase := Rectangle {
6 property<duration> d1: 100ms;
7 property<duration> d2: 3s;
8 property<duration> d3: 1.5s;
9 property<duration> d4: 30 * 1ms;
10 property<duration> d5: 8ms + 3s;
11 property<duration> d6: d1 - d2;
12 property<duration> d7: -0.5s;
13 property<duration> d8: -0.5s / 2 * 1px / 1px;
14 property<int> i1: d1 / 1ms;
15 property<int> i2: d1 / (2ms + 0);
16
17 property<int> untyped_d1: self.d1 / 1ms;
18 property<int> untyped_d2: self.d2 / 1ms;
19 property<int> untyped_d3: self.d3 / 1ms;
20 property<int> untyped_d4: self.d4 / 1ms;
21 property<int> untyped_d5: self.d5 / 1ms;
22 property<int> untyped_d6: self.d6 / 1ms;
23 property<int> untyped_d7: self.d7 / 1ms;
24 property<int> untyped_d8: self.d8 / 1ms;
25}
26
27
28/*
29```cpp
30auto handle = TestCase::create();
31const TestCase &instance = *handle;
32assert_eq(instance.get_untyped_d1(), 100);
33assert_eq(instance.get_untyped_d2(), 3000);
34assert_eq(instance.get_untyped_d3(), 1500);
35assert_eq(instance.get_untyped_d4(), 30);
36assert_eq(instance.get_untyped_d5(), 3008);
37assert_eq(instance.get_untyped_d6(), -2900);
38assert_eq(instance.get_untyped_d7(), -500);
39assert_eq(instance.get_untyped_d8(), -250);
40assert_eq(instance.get_i1(), 100);
41assert_eq(instance.get_i2(), 50);
42```
43
44
45```rust
46let instance = TestCase::new().unwrap();
47assert_eq!(instance.get_untyped_d1(), 100);
48assert_eq!(instance.get_untyped_d2(), 3000);
49assert_eq!(instance.get_untyped_d3(), 1500);
50assert_eq!(instance.get_untyped_d4(), 30);
51assert_eq!(instance.get_untyped_d5(), 3008);
52assert_eq!(instance.get_untyped_d6(), -2900);
53assert_eq!(instance.get_untyped_d7(), -500);
54assert_eq!(instance.get_untyped_d8(), -250);
55assert_eq!(instance.get_i1(), 100);
56assert_eq!(instance.get_i2(), 50);
57```
58
59```js
60var instance = new slint.TestCase({});
61assert.equal(instance.untyped_d1, 100);
62assert.equal(instance.untyped_d2, 3000);
63assert.equal(instance.untyped_d3, 1500);
64assert.equal(instance.untyped_d4, 30);
65assert.equal(instance.untyped_d5, 3008);
66assert.equal(instance.untyped_d6, -2900);
67assert.equal(instance.untyped_d7, -500);
68assert.equal(instance.untyped_d8, -250);
69assert.equal(instance.i1, 100);
70assert.equal(instance.i2, 50);
71```
72*/
73}
74
75#[test] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
76 use i_slint_backend_testing as slint_testing;
77 slint_testing::init();
78 let instance = TestCase::new().unwrap();
79 assert_eq!(instance.get_untyped_d1(), 100);
80 assert_eq!(instance.get_untyped_d2(), 3000);
81 assert_eq!(instance.get_untyped_d3(), 1500);
82 assert_eq!(instance.get_untyped_d4(), 30);
83 assert_eq!(instance.get_untyped_d5(), 3008);
84 assert_eq!(instance.get_untyped_d6(), -2900);
85 assert_eq!(instance.get_untyped_d7(), -500);
86 assert_eq!(instance.get_untyped_d8(), -250);
87 assert_eq!(instance.get_i1(), 100);
88 assert_eq!(instance.get_i2(), 50);
89 Ok(())
90}