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<int> hello: 44; |
7 | |
8 | property<bool> t1: hello == 44 || hello == 45; |
9 | property<bool> t2: hello > 44 && hello < 46; |
10 | property<bool> t3: hello >= 44 && hello <= 46; |
11 | property<bool> t4: t1 || (t2 && t3); |
12 | property<bool> t5: t2 || hello + 3 != 4*10+4; |
13 | property<bool> t6: !t1 || 1 == 0; |
14 | |
15 | property<string> my_str: "hello" ; |
16 | property<bool> t7: my_str == "hello" ; |
17 | } |
18 | /* |
19 | ```cpp |
20 | auto handle = TestCase::create(); |
21 | const TestCase &instance = *handle; |
22 | assert_eq(instance.get_t1(), true); |
23 | assert_eq(instance.get_t2(), false); |
24 | assert_eq(instance.get_t3(), true); |
25 | assert_eq(instance.get_t4(), true); |
26 | assert_eq(instance.get_t5(), true); |
27 | assert_eq(instance.get_t6(), false); |
28 | assert_eq(instance.get_t7(), true); |
29 | |
30 | instance.set_hello(45); |
31 | assert_eq(instance.get_t1(), true); |
32 | assert_eq(instance.get_t2(), true); |
33 | assert_eq(instance.get_t3(), true); |
34 | assert_eq(instance.get_t4(), true); |
35 | assert_eq(instance.get_t5(), true); |
36 | assert_eq(instance.get_t6(), false); |
37 | |
38 | instance.set_hello(46); |
39 | assert_eq(instance.get_t1(), false); |
40 | assert_eq(instance.get_t2(), false); |
41 | assert_eq(instance.get_t3(), true); |
42 | assert_eq(instance.get_t4(), false); |
43 | assert_eq(instance.get_t5(), true); |
44 | assert_eq(instance.get_t6(), true); |
45 | |
46 | instance.set_hello(47); |
47 | assert_eq(instance.get_t1(), false); |
48 | assert_eq(instance.get_t2(), false); |
49 | assert_eq(instance.get_t3(), false); |
50 | assert_eq(instance.get_t4(), false); |
51 | assert_eq(instance.get_t5(), true); |
52 | assert_eq(instance.get_t6(), true); |
53 | |
54 | instance.set_hello(41); |
55 | assert_eq(instance.get_t1(), false); |
56 | assert_eq(instance.get_t2(), false); |
57 | assert_eq(instance.get_t3(), false); |
58 | assert_eq(instance.get_t4(), false); |
59 | assert_eq(instance.get_t5(), false); |
60 | assert_eq(instance.get_t6(), true); |
61 | |
62 | ``` |
63 | |
64 | |
65 | ```rust |
66 | let instance = TestCase::new().unwrap(); |
67 | |
68 | assert_eq!(instance.get_t1(), true); |
69 | assert_eq!(instance.get_t2(), false); |
70 | assert_eq!(instance.get_t3(), true); |
71 | assert_eq!(instance.get_t4(), true); |
72 | assert_eq!(instance.get_t5(), true); |
73 | assert_eq!(instance.get_t6(), false); |
74 | assert_eq!(instance.get_t7(), true); |
75 | |
76 | instance.set_hello(45); |
77 | assert_eq!(instance.get_t1(), true); |
78 | assert_eq!(instance.get_t2(), true); |
79 | assert_eq!(instance.get_t3(), true); |
80 | assert_eq!(instance.get_t4(), true); |
81 | assert_eq!(instance.get_t5(), true); |
82 | assert_eq!(instance.get_t6(), false); |
83 | |
84 | instance.set_hello(46); |
85 | assert_eq!(instance.get_t1(), false); |
86 | assert_eq!(instance.get_t2(), false); |
87 | assert_eq!(instance.get_t3(), true); |
88 | assert_eq!(instance.get_t4(), false); |
89 | assert_eq!(instance.get_t5(), true); |
90 | assert_eq!(instance.get_t6(), true); |
91 | |
92 | instance.set_hello(47); |
93 | assert_eq!(instance.get_t1(), false); |
94 | assert_eq!(instance.get_t2(), false); |
95 | assert_eq!(instance.get_t3(), false); |
96 | assert_eq!(instance.get_t4(), false); |
97 | assert_eq!(instance.get_t5(), true); |
98 | assert_eq!(instance.get_t6(), true); |
99 | |
100 | instance.set_hello(41); |
101 | assert_eq!(instance.get_t1(), false); |
102 | assert_eq!(instance.get_t2(), false); |
103 | assert_eq!(instance.get_t3(), false); |
104 | assert_eq!(instance.get_t4(), false); |
105 | assert_eq!(instance.get_t5(), false); |
106 | assert_eq!(instance.get_t6(), true); |
107 | |
108 | ``` |
109 | |
110 | ```js |
111 | var instance = new slint.TestCase({}); |
112 | assert.equal(instance.t1, true); |
113 | assert.equal(instance.t2, false); |
114 | assert.equal(instance.t3, true); |
115 | assert.equal(instance.t4, true); |
116 | assert.equal(instance.t5, true); |
117 | assert.equal(instance.t6, false); |
118 | assert.equal(instance.t7, true); |
119 | |
120 | instance.hello = 45; |
121 | assert.equal(instance.t1, true); |
122 | assert.equal(instance.t2, true); |
123 | assert.equal(instance.t3, true); |
124 | assert.equal(instance.t4, true); |
125 | assert.equal(instance.t5, true); |
126 | assert.equal(instance.t6, false); |
127 | |
128 | instance.hello = 46; |
129 | assert.equal(instance.t1, false); |
130 | assert.equal(instance.t2, false); |
131 | assert.equal(instance.t3, true); |
132 | assert.equal(instance.t4, false); |
133 | assert.equal(instance.t5, true); |
134 | assert.equal(instance.t6, true); |
135 | |
136 | instance.hello = 47; |
137 | assert.equal(instance.t1, false); |
138 | assert.equal(instance.t2, false); |
139 | assert.equal(instance.t3, false); |
140 | assert.equal(instance.t4, false); |
141 | assert.equal(instance.t5, true); |
142 | assert.equal(instance.t6, true); |
143 | |
144 | instance.hello = 41; |
145 | assert.equal(instance.t1, false); |
146 | assert.equal(instance.t2, false); |
147 | assert.equal(instance.t3, false); |
148 | assert.equal(instance.t4, false); |
149 | assert.equal(instance.t5, false); |
150 | assert.equal(instance.t6, true); |
151 | ``` |
152 | */ |
153 | } |
154 | |
155 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
156 | use i_slint_backend_testing as slint_testing; |
157 | slint_testing::init(); |
158 | let instance = TestCase::new().unwrap(); |
159 | |
160 | assert_eq!(instance.get_t1(), true); |
161 | assert_eq!(instance.get_t2(), false); |
162 | assert_eq!(instance.get_t3(), true); |
163 | assert_eq!(instance.get_t4(), true); |
164 | assert_eq!(instance.get_t5(), true); |
165 | assert_eq!(instance.get_t6(), false); |
166 | assert_eq!(instance.get_t7(), true); |
167 | |
168 | instance.set_hello(45); |
169 | assert_eq!(instance.get_t1(), true); |
170 | assert_eq!(instance.get_t2(), true); |
171 | assert_eq!(instance.get_t3(), true); |
172 | assert_eq!(instance.get_t4(), true); |
173 | assert_eq!(instance.get_t5(), true); |
174 | assert_eq!(instance.get_t6(), false); |
175 | |
176 | instance.set_hello(46); |
177 | assert_eq!(instance.get_t1(), false); |
178 | assert_eq!(instance.get_t2(), false); |
179 | assert_eq!(instance.get_t3(), true); |
180 | assert_eq!(instance.get_t4(), false); |
181 | assert_eq!(instance.get_t5(), true); |
182 | assert_eq!(instance.get_t6(), true); |
183 | |
184 | instance.set_hello(47); |
185 | assert_eq!(instance.get_t1(), false); |
186 | assert_eq!(instance.get_t2(), false); |
187 | assert_eq!(instance.get_t3(), false); |
188 | assert_eq!(instance.get_t4(), false); |
189 | assert_eq!(instance.get_t5(), true); |
190 | assert_eq!(instance.get_t6(), true); |
191 | |
192 | instance.set_hello(41); |
193 | assert_eq!(instance.get_t1(), false); |
194 | assert_eq!(instance.get_t2(), false); |
195 | assert_eq!(instance.get_t3(), false); |
196 | assert_eq!(instance.get_t4(), false); |
197 | assert_eq!(instance.get_t5(), false); |
198 | assert_eq!(instance.get_t6(), true); |
199 | |
200 | Ok(()) |
201 | } |