Browse Source

Test foreach() loop.

release/v0.1
Rafal Kupiec 2 years ago
parent
commit
73c1a814f5
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
2 changed files with 33 additions and 0 deletions
  1. +21
    -0
      tests/loop_foreach_test.aer
  2. +12
    -0
      tests/loop_foreach_test.exp

+ 21
- 0
tests/loop_foreach_test.aer View File

@ -0,0 +1,21 @@
class Program {
void main() {
int[] $numbers = {'five' => 5, 'six' => 6, 'seven' => 7, 'eight' => 8, 'nine' => 9, 'zero' => 0};
string[] $days = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
foreach(string $key => int $numeric in $numbers) {
if($numeric == 6) {
continue;
}
print("$key is $numeric\n");
if($numeric == 8) {
break;
}
}
print("\nA week has seven days:\n");
foreach(string $day in $days) {
print("$day\n");
}
}
}

+ 12
- 0
tests/loop_foreach_test.exp View File

@ -0,0 +1,12 @@
five is 5
seven is 7
eight is 8
A week has seven days:
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday

Loading…
Cancel
Save