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 | TestCase := Rectangle { |
6 | property<float> t1: sin(0); |
7 | property<float> t2: sin(180deg); |
8 | property<float> t3: sin(30deg); |
9 | property<float> t4: sin(90deg); |
10 | } |
11 | /* |
12 | ```cpp |
13 | auto handle = TestCase::create(); |
14 | const TestCase &instance = *handle; |
15 | assert(std::abs(instance.get_t1()) < 0.0001); |
16 | assert(std::abs(instance.get_t2()) < 0.0001); |
17 | assert(std::abs(instance.get_t3() - 0.5) < 0.0001); |
18 | assert(std::abs(instance.get_t4() - 1.0) < 0.0001); |
19 | ``` |
20 | |
21 | ```rust |
22 | let instance = TestCase::new().unwrap(); |
23 | assert!(instance.get_t1().abs() < 0.0001); |
24 | assert!(instance.get_t2().abs() < 0.0001); |
25 | assert!((instance.get_t3() - 0.5).abs() < 0.0001); |
26 | assert!((instance.get_t4() - 1.0).abs() < 0.0001); |
27 | ``` |
28 | |
29 | ```js |
30 | var instance = new slint.TestCase({}); |
31 | assert(Math.abs(instance.t1) < 0.0001); |
32 | assert(Math.abs(instance.t2) < 0.0001); |
33 | assert(Math.abs(instance.t3 - 0.5) < 0.0001); |
34 | assert(Math.abs(instance.t4 - 1) < 0.0001); |
35 | ``` |
36 | */ |
37 | } |
38 | |
39 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
40 | use i_slint_backend_testing as slint_testing; |
41 | slint_testing::init(); |
42 | let instance = TestCase::new().unwrap(); |
43 | assert!(instance.get_t1().abs() < 0.0001); |
44 | assert!(instance.get_t2().abs() < 0.0001); |
45 | assert!((instance.get_t3() - 0.5).abs() < 0.0001); |
46 | assert!((instance.get_t4() - 1.0).abs() < 0.0001); |
47 | Ok(()) |
48 | } |