1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/globals"# ] |
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 | |
6 | global Numbers := { |
7 | property <int> three: 3; |
8 | property <int> ten: three * Numbers.three + 1; |
9 | } |
10 | |
11 | export global A := { |
12 | property <int> a_alias <=> a; |
13 | property <int> a: 3; |
14 | property <int> b: a + three; |
15 | property <int> three: Numbers.three; |
16 | } |
17 | |
18 | export global B := { |
19 | // property <int> a_alias <=> A.a_alias; |
20 | property <int> c: { |
21 | debug(A.b, Numbers.ten); |
22 | A.b + Numbers.ten; |
23 | } |
24 | } |
25 | |
26 | TestCase := Rectangle { |
27 | callback set_a(int); |
28 | set_a(a) => { |
29 | A.a_alias = a; |
30 | } |
31 | property <int> value1: B.c; |
32 | property <bool> test: value1 == 3 + 13; |
33 | } |
34 | |
35 | /* |
36 | ```rust |
37 | let instance = TestCase::new().unwrap(); |
38 | assert_eq!(instance.get_value1(), 3 + 13); |
39 | instance.invoke_set_a(4); |
40 | assert_eq!(instance.get_value1(), 4 + 13); |
41 | ``` |
42 | |
43 | ```cpp |
44 | auto handle = TestCase::create(); |
45 | const TestCase &instance = *handle; |
46 | assert_eq(instance.get_value1(), 3 + 13); |
47 | instance.invoke_set_a(4); |
48 | assert_eq(instance.get_value1(), 4 + 13); |
49 | ``` |
50 | |
51 | ```js |
52 | let instance = new slint.TestCase({}); |
53 | assert.equal(instance.value1, 3 + 13); |
54 | instance.set_a(4); |
55 | assert.equal(instance.value1, 4 + 13); |
56 | ``` |
57 | |
58 | */ |
59 | } |
60 | |
61 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
62 | use i_slint_backend_testing as slint_testing; |
63 | slint_testing::init(); |
64 | let instance = TestCase::new().unwrap(); |
65 | assert_eq!(instance.get_value1(), 3 + 13); |
66 | instance.invoke_set_a(4); |
67 | assert_eq!(instance.get_value1(), 4 + 13); |
68 | Ok(()) |
69 | } |