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 | Test := Rectangle { |
6 | property<angle> angle: 0.25turn; |
7 | property<bool> test: abs((angle - 0.5rad * 3.1415926535)/1grad) < 0.00001; |
8 | } |
9 | |
10 | /* |
11 | ```cpp |
12 | auto handle = Test::create(); |
13 | const Test &t = *handle; |
14 | assert_eq(t.get_angle(), 90.); |
15 | assert_eq(t.get_test(), true); |
16 | |
17 | t.set_angle(91.); |
18 | assert_eq(t.get_angle(), 91.); |
19 | assert_eq(t.get_test(), false); |
20 | ``` |
21 | |
22 | |
23 | ```rust |
24 | let t = Test::new().unwrap(); |
25 | assert_eq!(t.get_angle(), 90.); |
26 | assert_eq!(t.get_test(), true); |
27 | |
28 | t.set_angle(91.); |
29 | assert_eq!(t.get_angle(), 91.); |
30 | assert_eq!(t.get_test(), false); |
31 | ``` |
32 | |
33 | ```js |
34 | var t = new slint.Test({}); |
35 | assert.equal(t.angle, 90); |
36 | assert(t.test); |
37 | t.angle = 91; |
38 | assert.equal(t.angle, 91); |
39 | assert(!t.test); |
40 | |
41 | ``` |
42 | */ |
43 | } |
44 | |
45 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
46 | use i_slint_backend_testing as slint_testing; |
47 | slint_testing::init(); |
48 | let t = Test::new().unwrap(); |
49 | assert_eq!(t.get_angle(), 90.); |
50 | assert_eq!(t.get_test(), true); |
51 | |
52 | t.set_angle(91.); |
53 | assert_eq!(t.get_angle(), 91.); |
54 | assert_eq!(t.get_test(), false); |
55 | Ok(()) |
56 | } |