Skip to content

Commit

Permalink
Test for string concatenation
Browse files Browse the repository at this point in the history
  • Loading branch information
ogoffart committed Oct 19, 2020
1 parent 1791c15 commit 587b0a9
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/cases/expr/string_concatenation.60
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* LICENSE BEGIN
This file is part of the SixtyFPS Project -- https://sixtyfps.io
Copyright (c) 2020 Olivier Goffart <olivier.goffart@sixtyfps.io>
Copyright (c) 2020 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 */
TestCase := Rectangle {
property<int> a:12;
property<string> s1: "hello" + a + a;
property<string> s2: 10 + "hello" + 5.1;
property<string> s3: "x";
property<{ a: string }> obj: { a: "a" };
property<string> s4: obj.a + "xxx";
signal foo;
foo => {
s3 += a;
s3 += s3;
obj.a += "yo";
}
}
/*
```cpp
TestCase instance;
assert_eq(instance.get_s1(), sixtyfps::SharedString("hello1212"));
assert_eq(instance.get_s2(), sixtyfps::SharedString("10hello5.1"));
instance.set_a(42);
assert_eq(instance.get_s1(), sixtyfps::SharedString("hello4242"));
instance.emit_foo();
assert_eq(instance.get_s3(), sixtyfps::SharedString("x42x42"));
assert_eq(instance.get_s4(), sixtyfps::SharedString("ayoxxx"));
```


```rust
let instance = TestCase::new();
let instance = instance.as_ref();
assert_eq!(instance.get_s1(), sixtyfps::SharedString::from("hello1212"));
assert_eq!(instance.get_s2(), sixtyfps::SharedString::from("10hello5.1"));
instance.set_a(42);
assert_eq!(instance.get_s1(), sixtyfps::SharedString::from("hello4242"));
instance.emit_foo();
assert_eq!(instance.get_s3(), sixtyfps::SharedString::from("x42x42"));
assert_eq!(instance.get_s4(), sixtyfps::SharedString::from("ayoxxx"));
```

```js
var instance = new sixtyfps.TestCase({});
assert.equal(instance.s1, "hello1212");
assert.equal(instance.s2, "10hello5.1");
instance.a = 42;
assert.equal(instance.s1, "hello4242");
instance.foo();
assert.equal(instance.s3, "x42x42");
assert.equal(instance.s4, "ayoxxx");
```
*/

0 comments on commit 587b0a9

Please sign in to comment.