-
Notifications
You must be signed in to change notification settings - Fork 582
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Round the value. The previous behavior is that - For the interpreter, we were rounding (same as new behavior) - for Rust and C++ we were truncating, unless the properties were inlinined and then we were keeping it as float
- Loading branch information
Showing
5 changed files
with
59 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 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 | ||
|
||
export component TestCase { | ||
|
||
property <float> float-var: 26.7; | ||
// Going through a private property of type int should really cast to int | ||
private property <int> tens-digit-var: float-var / 10; | ||
|
||
// test that it rounds | ||
out property <int> int-val: -7.6; | ||
|
||
out property <string> text: tens-digit-var; | ||
out property <bool> test: tens-digit-var == 3 && text == "3" && int-val == -8; | ||
} | ||
|
||
|
||
/* | ||
```cpp | ||
auto handle = TestCase::create(); | ||
const TestCase &instance = *handle; | ||
assert_eq(instance.get_text(), "3"); | ||
assert_eq(instance.get_int_val(), -8); | ||
assert(instance.get_test()); | ||
``` | ||
```rust | ||
let instance = TestCase::new().unwrap(); | ||
assert_eq!(instance.get_text(), "3"); | ||
assert_eq!(instance.get_int_val(), -8); | ||
assert!(instance.get_test()); | ||
``` | ||
```js | ||
var instance = new slint.TestCase({}); | ||
assert.equal(instance.text, "3"); | ||
assert.equal(instance.int_val, -8); | ||
assert(instance.test); | ||
``` | ||
*/ |