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
5TestCase := 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
20auto handle = TestCase::create();
21const TestCase &instance = *handle;
22assert_eq(instance.get_t1(), true);
23assert_eq(instance.get_t2(), false);
24assert_eq(instance.get_t3(), true);
25assert_eq(instance.get_t4(), true);
26assert_eq(instance.get_t5(), true);
27assert_eq(instance.get_t6(), false);
28assert_eq(instance.get_t7(), true);
29
30instance.set_hello(45);
31assert_eq(instance.get_t1(), true);
32assert_eq(instance.get_t2(), true);
33assert_eq(instance.get_t3(), true);
34assert_eq(instance.get_t4(), true);
35assert_eq(instance.get_t5(), true);
36assert_eq(instance.get_t6(), false);
37
38instance.set_hello(46);
39assert_eq(instance.get_t1(), false);
40assert_eq(instance.get_t2(), false);
41assert_eq(instance.get_t3(), true);
42assert_eq(instance.get_t4(), false);
43assert_eq(instance.get_t5(), true);
44assert_eq(instance.get_t6(), true);
45
46instance.set_hello(47);
47assert_eq(instance.get_t1(), false);
48assert_eq(instance.get_t2(), false);
49assert_eq(instance.get_t3(), false);
50assert_eq(instance.get_t4(), false);
51assert_eq(instance.get_t5(), true);
52assert_eq(instance.get_t6(), true);
53
54instance.set_hello(41);
55assert_eq(instance.get_t1(), false);
56assert_eq(instance.get_t2(), false);
57assert_eq(instance.get_t3(), false);
58assert_eq(instance.get_t4(), false);
59assert_eq(instance.get_t5(), false);
60assert_eq(instance.get_t6(), true);
61
62```
63
64
65```rust
66let instance = TestCase::new().unwrap();
67
68assert_eq!(instance.get_t1(), true);
69assert_eq!(instance.get_t2(), false);
70assert_eq!(instance.get_t3(), true);
71assert_eq!(instance.get_t4(), true);
72assert_eq!(instance.get_t5(), true);
73assert_eq!(instance.get_t6(), false);
74assert_eq!(instance.get_t7(), true);
75
76instance.set_hello(45);
77assert_eq!(instance.get_t1(), true);
78assert_eq!(instance.get_t2(), true);
79assert_eq!(instance.get_t3(), true);
80assert_eq!(instance.get_t4(), true);
81assert_eq!(instance.get_t5(), true);
82assert_eq!(instance.get_t6(), false);
83
84instance.set_hello(46);
85assert_eq!(instance.get_t1(), false);
86assert_eq!(instance.get_t2(), false);
87assert_eq!(instance.get_t3(), true);
88assert_eq!(instance.get_t4(), false);
89assert_eq!(instance.get_t5(), true);
90assert_eq!(instance.get_t6(), true);
91
92instance.set_hello(47);
93assert_eq!(instance.get_t1(), false);
94assert_eq!(instance.get_t2(), false);
95assert_eq!(instance.get_t3(), false);
96assert_eq!(instance.get_t4(), false);
97assert_eq!(instance.get_t5(), true);
98assert_eq!(instance.get_t6(), true);
99
100instance.set_hello(41);
101assert_eq!(instance.get_t1(), false);
102assert_eq!(instance.get_t2(), false);
103assert_eq!(instance.get_t3(), false);
104assert_eq!(instance.get_t4(), false);
105assert_eq!(instance.get_t5(), false);
106assert_eq!(instance.get_t6(), true);
107
108```
109
110```js
111var instance = new slint.TestCase({});
112assert.equal(instance.t1, true);
113assert.equal(instance.t2, false);
114assert.equal(instance.t3, true);
115assert.equal(instance.t4, true);
116assert.equal(instance.t5, true);
117assert.equal(instance.t6, false);
118assert.equal(instance.t7, true);
119
120instance.hello = 45;
121assert.equal(instance.t1, true);
122assert.equal(instance.t2, true);
123assert.equal(instance.t3, true);
124assert.equal(instance.t4, true);
125assert.equal(instance.t5, true);
126assert.equal(instance.t6, false);
127
128instance.hello = 46;
129assert.equal(instance.t1, false);
130assert.equal(instance.t2, false);
131assert.equal(instance.t3, true);
132assert.equal(instance.t4, false);
133assert.equal(instance.t5, true);
134assert.equal(instance.t6, true);
135
136instance.hello = 47;
137assert.equal(instance.t1, false);
138assert.equal(instance.t2, false);
139assert.equal(instance.t3, false);
140assert.equal(instance.t4, false);
141assert.equal(instance.t5, true);
142assert.equal(instance.t6, true);
143
144instance.hello = 41;
145assert.equal(instance.t1, false);
146assert.equal(instance.t2, false);
147assert.equal(instance.t3, false);
148assert.equal(instance.t4, false);
149assert.equal(instance.t5, false);
150assert.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}