slint/tests/cases/expr/sqrt.slint
2023-07-10 10:12:11 +02:00

27 lines
713 B
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
TestCase := Rectangle {
property<float> t1: sqrt(100.0);
property<float> t2: sqrt(2);
}
/*
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert_eq(instance.get_t1(), 10.0);
assert(std::abs(instance.get_t2() - 1.414214) < 0.0001);
```
```rust
let instance = TestCase::new().unwrap();
assert_eq!(instance.get_t1(), 10.0);
assert!((instance.get_t2() - 1.414214).abs() < 0.0001);
```
```js
var instance = new slint.TestCase({});
assert.equal(instance.t1, 10);
assert(Math.abs(instance.t2 - 1.414214) < 0.0001);
```
*/