slint/tests/cases/callbacks/callback_alias.60
2021-08-17 22:38:16 +02:00

66 lines
1.7 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 */
Foo := Rectangle {
callback hallo_alias <=> xxx.hallo;
callback clicked <=> are.clicked;
xxx := Rectangle {
callback hallo(int) -> int;
hallo(a) => { return a + 88; }
}
are := TouchArea { }
}
TestCase := Rectangle {
callback foo1_alias <=> foo1.hallo_alias;
callback foo2_alias <=> foo2.hallo_alias;
callback foo1_clicked <=> foo1.clicked;
callback call_foo2(int) -> int;
call_foo2(a) => { return foo2.hallo_alias(a); }
foo1 := Foo {
hallo_alias(a) => { return a + 22; }
}
foo2 := Foo {
clicked => { debug(42) }
}
property <bool> test: foo1_alias(100) == 122 && foo2_alias(100) == 188;
}
/*
```rust
let instance = TestCase::new();
assert_eq!(instance.invoke_foo1_alias(100), 122);
assert_eq!(instance.invoke_foo2_alias(100), 188);
assert_eq!(instance.invoke_call_foo2(100), 188);
```
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert_eq(instance.invoke_foo1_alias(100), 122);
assert_eq(instance.invoke_foo2_alias(100), 188);
assert_eq(instance.invoke_call_foo2(100), 188);
```
```js
var instance = new sixtyfps.TestCase();
assert.equal(instance.foo1_alias(100), 122);
assert.equal(instance.foo2_alias(100), 188);
assert.equal(instance.call_foo2(100), 188);
```
*/