| 1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
| 2 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 |
| 3 | |
| 4 | TestCase := Rectangle { |
| 5 | property<int> a:12; |
| 6 | property<string> s1: "hello" + a + a; |
| 7 | property<string> s2: 10 + "hello" + 5.1; |
| 8 | property<string> s3: "x" ; |
| 9 | property<{ a: string }> obj: { a: "a" }; |
| 10 | property<string> s4: obj.a + "xxx" ; |
| 11 | callback foo; |
| 12 | foo => { |
| 13 | s3 += a; |
| 14 | s3 += s3; |
| 15 | obj.a += "yo" ; |
| 16 | } |
| 17 | |
| 18 | property <bool> test: (s1 + s1 + obj.a + obj.a) == "hello1212hello1212aa" ; |
| 19 | } |
| 20 | /* |
| 21 | ```cpp |
| 22 | auto handle = TestCase::create(); |
| 23 | const TestCase &instance = *handle; |
| 24 | assert_eq(instance.get_s1(), slint::SharedString("hello1212")); |
| 25 | assert_eq(instance.get_s2(), slint::SharedString("10hello5.1")); |
| 26 | instance.set_a(42); |
| 27 | assert_eq(instance.get_s1(), slint::SharedString("hello4242")); |
| 28 | instance.invoke_foo(); |
| 29 | assert_eq(instance.get_s3(), slint::SharedString("x42x42")); |
| 30 | assert_eq(instance.get_s4(), slint::SharedString("ayoxxx")); |
| 31 | ``` |
| 32 | |
| 33 | |
| 34 | ```rust |
| 35 | let instance = TestCase::new().unwrap(); |
| 36 | assert_eq!(instance.get_s1(), slint::SharedString::from("hello1212")); |
| 37 | assert_eq!(instance.get_s2(), slint::SharedString::from("10hello5.1")); |
| 38 | instance.set_a(42); |
| 39 | assert_eq!(instance.get_s1(), slint::SharedString::from("hello4242")); |
| 40 | instance.invoke_foo(); |
| 41 | assert_eq!(instance.get_s3(), slint::SharedString::from("x42x42")); |
| 42 | assert_eq!(instance.get_s4(), slint::SharedString::from("ayoxxx")); |
| 43 | ``` |
| 44 | |
| 45 | ```js |
| 46 | var instance = new slint.TestCase({}); |
| 47 | assert.equal(instance.s1, "hello1212"); |
| 48 | assert.equal(instance.s2, "10hello5.1"); |
| 49 | instance.a = 42; |
| 50 | assert.equal(instance.s1, "hello4242"); |
| 51 | instance.foo(); |
| 52 | assert.equal(instance.s3, "x42x42"); |
| 53 | assert.equal(instance.s4, "ayoxxx"); |
| 54 | ``` |
| 55 | */ |
| 56 | |