| 1 |
-- main.mcl -- |
| 2 |
$l1 = ["a", "b", "c",] |
| 3 |
|
| 4 |
$l2 = [$l1, ["hello", "world",],] |
| 5 |
|
| 6 |
test [$l1[0] || "fail",] {} |
| 7 |
test [$l1[2] || "fail",] {} |
| 8 |
test [$l1[3] || "pass",] {} |
| 9 |
test $l2[1] || ["fail",] {} |
| 10 |
|
| 11 |
$map1 map{int: str} = {42 => "hello1",} |
| 12 |
$name1 = $map1[42] || "not found" |
| 13 |
test "${name1}" {} |
| 14 |
|
| 15 |
$map2 map{int: str} = {42 => "hello2",} |
| 16 |
$name2 = $map2[13] || "world2" |
| 17 |
test "${name2}" {} |
| 18 |
|
| 19 |
$map3 = {42 => "hello3",} |
| 20 |
$name3 = $map3[42] || "not found" |
| 21 |
test "${name3}" {} |
| 22 |
|
| 23 |
$map4 = {42 => "hello4",} |
| 24 |
$name4 = $map4[13] || "world4" |
| 25 |
test "${name4}" {} |
| 26 |
|
| 27 |
$map5 = {"wow" => "pass1",} |
| 28 |
$name5 = $map5["wow"] || "fail" |
| 29 |
test "${name5}" {} |
| 30 |
|
| 31 |
$map6 = {"wow" => "fail",} |
| 32 |
$name6 = $map6["mom"] || "pass2" |
| 33 |
test "${name6}" {} |
| 34 |
|
| 35 |
-- OUTPUT -- |
| 36 |
Vertex: test[a] |
| 37 |
Vertex: test[c] |
| 38 |
Vertex: test[hello1] |
| 39 |
Vertex: test[hello3] |
| 40 |
Vertex: test[hello] |
| 41 |
Vertex: test[pass1] |
| 42 |
Vertex: test[pass2] |
| 43 |
Vertex: test[pass] |
| 44 |
Vertex: test[world2] |
| 45 |
Vertex: test[world4] |
| 46 |
Vertex: test[world] |