1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
2 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
3 | |
4 | export component TestCase { |
5 | in-out property<string> p1: "hello" ; |
6 | in-out property<string> p2: "fox:🦊" ; |
7 | in-out property<string> p3: "with\"quote\\\" \u{8}"; |
8 | in-out property<bool> e1: p2 == " fox:🦊"; |
9 | in-out property<bool> e2: p2 == " fox:🦍"; |
10 | |
11 | // conversion from float |
12 | in property<float> value: 98.7654321; |
13 | out property <string> converted_value: round(value * 100)/100; |
14 | out property <bool> test: e1 && !e2 && converted_value == " 98.77"; |
15 | } |
16 | |
17 | |
18 | /* |
19 | |
20 | ```cpp |
21 | auto handle = TestCase::create(); |
22 | const TestCase &instance = *handle; |
23 | assert_eq(instance.get_p1(), " hello"); |
24 | assert_eq(instance.get_p2(), " fox:🦊"); |
25 | assert_eq(instance.get_p3(), " with\"quote\\\"\x08" ); |
26 | assert(instance.get_e1()); |
27 | assert(!instance.get_e2()); |
28 | assert(instance.get_test()); |
29 | ``` |
30 | |
31 | ```rust |
32 | let instance = TestCase::new().unwrap(); |
33 | assert_eq!(instance.get_p1(), "hello" ); |
34 | assert_eq!(instance.get_p2(), "fox:🦊" ); |
35 | assert_eq!(instance.get_p3(), "with\"quote\\\" \u{8}"); |
36 | assert!(instance.get_e1()); |
37 | assert!(!instance.get_e2()); |
38 | assert!(instance.get_test()); |
39 | ``` |
40 | |
41 | ```js |
42 | var instance = new slint.TestCase({}); |
43 | assert.equal(instance.p1, " hello"); |
44 | assert.equal(instance.p2, " fox:🦊"); |
45 | assert.equal(instance.p3, " with\"quote\\\"\u0008" ); |
46 | assert(instance.e1); |
47 | assert(!instance.e2); |
48 | assert(instance.test); |
49 | ``` |
50 | |
51 | */ |
52 | |