From b302e8c2b2ba8e7971ee772de743d01c656625b1 Mon Sep 17 00:00:00 2001 From: belliash Date: Thu, 11 Apr 2019 13:29:44 +0200 Subject: [PATCH] Test static variables. --- tests/static_var.aer | 24 ++++++++++++++++++++++++ tests/static_var.exp | 26 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 tests/static_var.aer create mode 100644 tests/static_var.exp diff --git a/tests/static_var.aer b/tests/static_var.aer new file mode 100644 index 0000000..b2b552c --- /dev/null +++ b/tests/static_var.aer @@ -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); + } + } + } + } + +} diff --git a/tests/static_var.exp b/tests/static_var.exp new file mode 100644 index 0000000..7a256fb --- /dev/null +++ b/tests/static_var.exp @@ -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