mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 06:41:14 +00:00
54 lines
1.4 KiB
Text
54 lines
1.4 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 */
|
|
|
|
export TestCase := Rectangle {
|
|
property<[int]> ints: [1, 2, 3, 4, 5];
|
|
property<int> num_ints: ints.length;
|
|
}
|
|
|
|
/*
|
|
```cpp
|
|
auto handle = TestCase::create();
|
|
const TestCase &instance = *handle;
|
|
|
|
assert_eq(instance.get_num_ints(), 5);
|
|
|
|
auto model = std::make_shared<sixtyfps::VectorModel<int>>(std::vector<int>{1, 2, 3, 4, 5, 6, 7});
|
|
instance.set_ints(model);
|
|
assert_eq(instance.get_num_ints(), 7);
|
|
model->push_back(8);
|
|
assert_eq(instance.get_num_ints(), 8);
|
|
```
|
|
|
|
|
|
```rust
|
|
let instance = TestCase::new();
|
|
|
|
assert_eq!(instance.get_num_ints(), 5);
|
|
|
|
let model: std::rc::Rc<sixtyfps::VecModel<i32>> = std::rc::Rc::new(vec![1, 2, 3, 4, 5, 6, 7].into());
|
|
instance.set_ints(sixtyfps::ModelHandle::new(model.clone()));
|
|
assert_eq!(instance.get_num_ints(), 7);
|
|
model.push(8);
|
|
assert_eq!(instance.get_num_ints(), 8);
|
|
```
|
|
|
|
```js
|
|
var instance = new sixtyfps.TestCase();
|
|
|
|
assert.equal(instance.num_ints, 5);
|
|
|
|
let model = new sixtyfpslib.ArrayModel([1, 2, 3, 4, 5, 6, 7]);
|
|
instance.ints = model;
|
|
assert.equal(instance.num_ints, 7);
|
|
model.push(8);
|
|
assert.equal(instance.num_ints, 8);
|
|
```
|
|
*/
|