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 | |
5 | TestCase := 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 |
30 | auto handle = TestCase::create(); |
31 | const TestCase &instance = *handle; |
32 | assert_eq(instance.get_untyped_d1(), 100); |
33 | assert_eq(instance.get_untyped_d2(), 3000); |
34 | assert_eq(instance.get_untyped_d3(), 1500); |
35 | assert_eq(instance.get_untyped_d4(), 30); |
36 | assert_eq(instance.get_untyped_d5(), 3008); |
37 | assert_eq(instance.get_untyped_d6(), -2900); |
38 | assert_eq(instance.get_untyped_d7(), -500); |
39 | assert_eq(instance.get_untyped_d8(), -250); |
40 | assert_eq(instance.get_i1(), 100); |
41 | assert_eq(instance.get_i2(), 50); |
42 | ``` |
43 | |
44 | |
45 | ```rust |
46 | let instance = TestCase::new().unwrap(); |
47 | assert_eq!(instance.get_untyped_d1(), 100); |
48 | assert_eq!(instance.get_untyped_d2(), 3000); |
49 | assert_eq!(instance.get_untyped_d3(), 1500); |
50 | assert_eq!(instance.get_untyped_d4(), 30); |
51 | assert_eq!(instance.get_untyped_d5(), 3008); |
52 | assert_eq!(instance.get_untyped_d6(), -2900); |
53 | assert_eq!(instance.get_untyped_d7(), -500); |
54 | assert_eq!(instance.get_untyped_d8(), -250); |
55 | assert_eq!(instance.get_i1(), 100); |
56 | assert_eq!(instance.get_i2(), 50); |
57 | ``` |
58 | |
59 | ```js |
60 | var instance = new slint.TestCase({}); |
61 | assert.equal(instance.untyped_d1, 100); |
62 | assert.equal(instance.untyped_d2, 3000); |
63 | assert.equal(instance.untyped_d3, 1500); |
64 | assert.equal(instance.untyped_d4, 30); |
65 | assert.equal(instance.untyped_d5, 3008); |
66 | assert.equal(instance.untyped_d6, -2900); |
67 | assert.equal(instance.untyped_d7, -500); |
68 | assert.equal(instance.untyped_d8, -250); |
69 | assert.equal(instance.i1, 100); |
70 | assert.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 | } |