File tree Expand file tree Collapse file tree 1 file changed +75
-0
lines changed
Expand file tree Collapse file tree 1 file changed +75
-0
lines changed Original file line number Diff line number Diff line change 1+ // Copyright © SixtyFPS GmbH <info@slint.dev>
2+ // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.2 OR LicenseRef-Slint-commercial
3+
4+
5+ component BackgroundExpr inherits Rectangle {
6+ in property <bool > cond ;
7+ // conversion from color to brush do a Cast expression and this should work even when there is a return
8+ background : {
9+ if (cond) {
10+ return blue;
11+ }
12+ red
13+ }
14+ }
15+ component BackgroundExpr2 inherits Rectangle {
16+ in property <int > val ;
17+ in property <bool > cond1 ;
18+ pure callback foo ();
19+ background : {
20+ if (val > 20 ) {
21+ if (val > 50 ) {
22+ return green;
23+ } else if val > 40 {
24+ return yellow;
25+ } else {
26+ return blue;
27+ };
28+ return black;
29+ }
30+ if val > 10 {
31+ return pink;
32+ } else {
33+ foo();
34+ }
35+ if val > 1 {
36+ red
37+ } else {
38+ orange
39+ }
40+
41+ }
42+ }
43+
44+ export component TestCase {
45+
46+ bkg1 := BackgroundExpr { cond : true ; }
47+ bkg2 := BackgroundExpr { cond : false ; }
48+ bkg3 := BackgroundExpr2 { val : 0 ; }
49+ bkg4 := BackgroundExpr2 { val : 11 ; }
50+ bkg5 := BackgroundExpr2 { val : 21 ; }
51+
52+
53+ out property <bool > test :
54+ {
55+ return bkg1. background == Colors .blue && bkg2. background == Colors .red
56+ && bkg3. background == Colors .orange && bkg4. background == Colors .pink && bkg5. background == Colors .blue ;
57+ }
58+
59+
60+ }
61+
62+
63+ /*
64+ ```cpp
65+ auto handle = TestCase::create();
66+ const TestCase &instance = *handle;
67+ assert(instance.get_test());
68+ ```
69+
70+ ```rust
71+ let instance = TestCase::new().unwrap();
72+ assert!(instance.get_test());
73+ ```
74+
75+ */
You can’t perform that action at this time.
0 commit comments