Browse Source

Test static variables.

pull/50/head
Rafal Kupiec 1 year ago
parent
commit
b302e8c2b2
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
2 changed files with 50 additions and 0 deletions
  1. +24
    -0
      tests/static_var.aer
  2. +26
    -0
      tests/static_var.exp

+ 24
- 0
tests/static_var.aer View File

@ -0,0 +1,24 @@
class Program {
string cycle(char $a, char $b, int $i = 0) {
static char[] $switches;
if($switches[$i])
$switches[$i] = !$switches[$i];
else
!($switches[$i] = true);
return ($switches[$i]) ? $a : $b;
}
void main() {
for(int $i = 1; $i < 3; $i++) {
print($i + $this->cycle('a', 'b') + PHP_EOL);
for(int $j = 1; $j < 5; $j++) {
print(' ' + $j + $this->cycle('a', 'b', 1) + PHP_EOL);
for(int $k = 1; $k < 3; $k++) {
print(' ' + $k + $this->cycle('c', 'd', 2) + PHP_EOL);
}
}
}
}
}

+ 26
- 0
tests/static_var.exp View File

@ -0,0 +1,26 @@
1a
1a
1c
2d
2b
1c
2d
3a
1c
2d
4b
1c
2d
2b
1a
1c
2d
2b
1c
2d
3a
1c
2d
4b
1c
2d

Loading…
Cancel
Save