slint/tests/cases/properties/dashes.slint
Tobias Hunger 63f7533dc9 compiler: Fix identifier normalization function
`__1` is a valid identifier, which we normalized to
`--1`, which is invalid.

This changes the nromalization function to leave a `_` in the first position.
2025-05-21 12:21:20 +02:00

66 lines
1.9 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
struct __strange- {
_-indeed--: int,
}
export global _-Foo-- {
out property<int> _-foo-: 815;
}
Test-Case := Rectangle {
property<length> property-x1: xxx-foo.border-width;
property<length> property-x2: xxx_foo.border_width;
__-id- := Rectangle {
property<_-strange-> struct-property: { _-indeed--: 23 };
}
xxx-foo := Rectangle {
border-width: 42phx;
}
property<int> hello-42: 42;
property<int> hello--world: -hello-42 - 2; // -42 - 2 = -44
property<int> this--has-6-slashes--: 42-hello--world; // 42 - -44 = 86
out property<int> _-test_property-: 42;
out property<int> __test_property2: _--id_.struct-property._-indeed--;
}
/*
```cpp
auto handle = Test_Case::create();
const Test_Case &instance = *handle;
assert_eq(instance.get_property_x1(), 42);
assert_eq(instance.get_property_x2(), 42);
assert_eq(instance.get_this__has_6_slashes__(), 86);
assert_eq(instance.get___test_property_(), 42);
assert_eq(instance.get___test_property2(), 23);
assert_eq(handle->global<__Foo__>().get___foo_(), 815);
```
```rust
let instance = Test_Case::new().unwrap();
assert_eq!(instance.get_property_x1(), 42.);
assert_eq!(instance.get_property_x2(), 42.);
assert_eq!(instance.get_this__has_6_slashes__(), 86);
assert_eq!(instance.get___test_property_(), 42);
assert_eq!(instance.get___test_property2(), 23);
let foo = instance.global::<__Foo__<'_>>();
assert_eq!(foo.get___foo_(), 815);
```
```js
var instance = new slint.Test_Case({});
assert.equal(instance.property_x1, 42);
assert.equal(instance.property_x2, 42);
assert.equal(instance.this__has_6_slashes__, 86);
assert.equal(instance.__test_property_, 42);
assert.equal(instance.__test_property2, 23);
assert.equal(instance.__Foo__.__foo_, 815);
```
*/