| 1 |
[ 1, 2, 3, 4, 5 ] @=> int a[]; |
| 2 |
[ 1, 2, 4, 5] @=> int a_expected[]; |
| 3 |
|
| 4 |
true => int success; |
| 5 |
|
| 6 |
if (a.size() != 5) { |
| 7 |
<<< "array is wrong size" >>>; |
| 8 |
false => success; |
| 9 |
} |
| 10 |
|
| 11 |
a.popOut( 2 ); |
| 12 |
|
| 13 |
fun int compareArr(int got[], int want[]) { |
| 14 |
if (got.size() != want.size()) { |
| 15 |
<<< "arrays have different sizes, got:", got.size(), "want:", want.size() >>>; |
| 16 |
return false; |
| 17 |
} |
| 18 |
|
| 19 |
for (0 => int i; i < got.size(); i++) { |
| 20 |
if (got[i] != want[i]) { |
| 21 |
<<< "incorrect values, want", want[i], "got", got[i] >>>; |
| 22 |
return false; |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
return true; |
| 27 |
} |
| 28 |
|
| 29 |
compareArr(a, a_expected) && success => success; |
| 30 |
|
| 31 |
// validate that resize is working as expected |
| 32 |
a << 6 << 7 << 8 << 9 << 10 << 11 << 12; |
| 33 |
|
| 34 |
[ 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] @=> a_expected; |
| 35 |
|
| 36 |
compareArr(a, a_expected) && success => success; |
| 37 |
|
| 38 |
// pop empty array |
| 39 |
[ 1 ] @=> int b[]; |
| 40 |
|
| 41 |
b.popOut(0); |
| 42 |
b.popOut(0); |
| 43 |
b.popOut(1); |
| 44 |
|
| 45 |
if (success) <<< "success" >>>; |