1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
2 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
3 | |
4 | |
5 | export struct Player := { |
6 | skill-profile: int, |
7 | } |
8 | export struct NewGameTeam := { |
9 | players: [Player], |
10 | } |
11 | export struct NewGameParameters := { |
12 | teams: [NewGameTeam], |
13 | } |
14 | |
15 | |
16 | struct StructWithArrayOfStruct := { prop: [{hello: string, world: int}], xxx: int } |
17 | |
18 | TestCase := Rectangle { |
19 | property <[int]> p1 : [ 12, 13 ]; |
20 | property <[float]> p2 : [ 14, 15.5 ]; |
21 | property <[string]> p3 : [ ]; |
22 | property <[{a: int, b: int}]> p4 : [ { a: 1 }, { a: 42, b: 10 } ]; |
23 | property <StructWithArrayOfStruct> p5 : { prop: [{hello: "hello" }, {world: 42.0 }]}; |
24 | |
25 | property <NewGameParameters> p6 : { teams: [{ players: [ { skill-profile: 9 } ] }] } ; |
26 | } |
27 | |
28 | |
29 | /* |
30 | ```js |
31 | var instance = new slint.TestCase({}); |
32 | assert.deepEqual(Array.from(instance.p1), [12, 13]); |
33 | assert.deepEqual(Array.from(instance.p2), [14, 15.5]); |
34 | assert.deepEqual(Array.from(instance.p3), []); |
35 | assert.deepEqual(Array.from(instance.p4), [{a: 1, b: 0}, {a: 42, b: 10}]); |
36 | let p5val = instance.p5; |
37 | p5val.prop = Array.from(p5val.prop); |
38 | assert.deepEqual(p5val, { prop: [{hello: "hello", world: 0}, { hello: "", world: 42}], xxx: 0 }); |
39 | |
40 | instance.p3 = ["Hello", "World"]; |
41 | assert.deepEqual(Array.from(instance.p3), ["Hello", "World"]); |
42 | ``` |
43 | */ |
44 | |