mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
59 lines
1.8 KiB
Text
59 lines
1.8 KiB
Text
/* LICENSE BEGIN
|
|
This file is part of the SixtyFPS Project -- https://sixtyfps.io
|
|
Copyright (c) 2021 Olivier Goffart <olivier.goffart@sixtyfps.io>
|
|
Copyright (c) 2021 Simon Hausmann <simon.hausmann@sixtyfps.io>
|
|
|
|
SPDX-License-Identifier: GPL-3.0-only
|
|
This file is also available under commercial licensing terms.
|
|
Please contact info@sixtyfps.io for more information.
|
|
LICENSE END */
|
|
TestCase := Rectangle {
|
|
property<bool> condition;
|
|
property<int> test_value: condition ? 1 : 2;
|
|
property<bool> condition2;
|
|
property<int> test_value2: condition ? condition2 ? 1 : 2 : condition2 ? 3 : 4;
|
|
|
|
property<length> test_value3: false ? 0 : 12phx;
|
|
}
|
|
/*
|
|
```cpp
|
|
auto handle = TestCase::create();
|
|
const TestCase &instance = *handle;
|
|
instance.set_condition(true);
|
|
assert_eq(instance.get_test_value(), 1);
|
|
assert_eq(instance.get_test_value2(), 2);
|
|
instance.set_condition(false);
|
|
assert_eq(instance.get_test_value(), 2);
|
|
assert_eq(instance.get_test_value2(), 4);
|
|
instance.set_condition2(true);
|
|
assert_eq(instance.get_test_value2(), 3);
|
|
assert_eq(instance.get_test_value3(), 12.);
|
|
```
|
|
|
|
|
|
```rust
|
|
let instance = TestCase::new();
|
|
instance.set_condition(true);
|
|
assert_eq!(instance.get_test_value(), 1);
|
|
assert_eq!(instance.get_test_value2(), 2);
|
|
instance.set_condition(false);
|
|
assert_eq!(instance.get_test_value(), 2);
|
|
assert_eq!(instance.get_test_value2(), 4);
|
|
instance.set_condition2(true);
|
|
assert_eq!(instance.get_test_value2(), 3);
|
|
assert_eq!(instance.get_test_value3(), 12.);
|
|
```
|
|
|
|
```js
|
|
var instance = new sixtyfps.TestCase({});
|
|
instance.condition = true;
|
|
assert.equal(instance.test_value, 1);
|
|
assert.equal(instance.test_value2, 2);
|
|
instance.condition = false;
|
|
assert.equal(instance.test_value, 2);
|
|
assert.equal(instance.test_value2, 4);
|
|
instance.condition2 = true;
|
|
assert.equal(instance.test_value2, 3);
|
|
assert.equal(instance.test_value3, 12);
|
|
```
|
|
*/
|