Debian Codegraph @

src/test/01-Basic/235-type-array.ck

raw
1 [1] @=> int arr_prim[];
2
3 if(!Type.of(arr_prim).isArray()) me.exit();
4
5 vec2 arr_vec2[0];
6 if(!Type.of(arr_vec2).isArray()) me.exit();
7
8 SinOsc arr_sin[0];
9 if(!Type.of(arr_sin).isArray()) me.exit();
10
11 // test Type.find() with arrays
12 if(!Type.find("int[]").isArray()) me.exit();
13 if(!Type.find("vec2[][][][]").isArray()) me.exit();
14 if(!Type.find("SinOsc[][]").isArray()) me.exit();
15 if(Type.find("float").isArray()) me.exit;
16
17 // test array type names
18 [ "a", "b", "c"] @=> string arr_s1[];
19 if(arr_s1.typeOf().name() != "string[]") me.exit();
20 // note: the follow would use to return more generic "@array"
21 // as of 1.5.4.0, Type.of() returns more specific type names
22 if(Type.of(arr_s1).name() != "string[]") me.exit();
23
24 // 2D arrays
25 [ ["a"], ["b"] ] @=> string arr_s2[][];
26 if(arr_s2.typeOf().name() != "string[][]") me.exit();
27 if(Type.of(arr_s2).name() != "string[][]") me.exit();
28
29 // if we got here, then...
30 <<< "success" >>>;