mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-23 00:32:46 +00:00

We must take care that all access to property that we consider constant in global are accessed after the global has been initialized. So initialize the global before the properties. Fixes #8375 , #8337
51 lines
1.3 KiB
Text
51 lines
1.3 KiB
Text
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
|
|
|
// This tests that constant property from global are properly initialized
|
|
|
|
global Glob {
|
|
in-out property <int> a: 3;
|
|
in-out property <int> b: a + 3;
|
|
}
|
|
|
|
global Glob2 {
|
|
in-out property <int> a: other;
|
|
in-out property <int> other: 5;
|
|
|
|
// A constant property that is not going to be inlined
|
|
out property <int> const-no-inline: {
|
|
debug("this debug message should make no-inline to not be inlined");
|
|
82
|
|
}
|
|
}
|
|
|
|
export component TestCase inherits Window {
|
|
r := Rectangle {
|
|
property <int> value1: Glob.b;
|
|
property <int> value2: true ? Glob2.a : 88;
|
|
}
|
|
out property <int> value3: Glob2.const-no-inline;
|
|
out property <bool> test: r.value1 + r.value2 == 3+3 +5 && value3 == 82;
|
|
}
|
|
|
|
/*
|
|
```rust
|
|
let instance = TestCase::new().unwrap();
|
|
assert_eq!(instance.get_value3(), 82);
|
|
assert!(instance.get_test());
|
|
```
|
|
|
|
```cpp
|
|
auto handle = TestCase::create();
|
|
const TestCase &instance = *handle;
|
|
assert_eq(instance.get_value3(), 82);
|
|
assert(instance.get_test());
|
|
```
|
|
|
|
```js
|
|
let instance = new slint.TestCase({});
|
|
assert.equal(instance.value3, 82);
|
|
assert(instance.test);
|
|
```
|
|
|
|
*/
|