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<angle> t1: atan(0); |
7 | property<angle> t2: atan((1/3) * sqrt(3)); |
8 | property<angle> t3: atan(1); |
9 | property<angle> t4: atan(sqrt(3)); |
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() - 30.0) < 0.0001); |
17 | assert(std::abs(instance.get_t3() - 45.0) < 0.0001); |
18 | assert(std::abs(instance.get_t4() - 60.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() - 30.0).abs() < 0.0001); |
25 | assert!((instance.get_t3() - 45.0).abs() < 0.0001); |
26 | assert!((instance.get_t4() - 60.0).abs() < 0.0001); |
27 | ``` |
28 | |
29 | ```js |
30 | var instance = new slint.TestCase({}); |
31 | assert.equal(instance.t1, 0); |
32 | assert.equal(instance.t2, 30); |
33 | assert.equal(instance.t3, 45); |
34 | assert.equal(instance.t4, 60); |
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() - 30.0).abs() < 0.0001); |
45 | assert!((instance.get_t3() - 45.0).abs() < 0.0001); |
46 | assert!((instance.get_t4() - 60.0).abs() < 0.0001); |
47 | Ok(()) |
48 | } |