From ff7369011155b71f22c9b4c74b5c71ea39ca6a51 Mon Sep 17 00:00:00 2001 From: belliash Date: Sun, 17 Mar 2019 19:48:52 +0100 Subject: [PATCH] Update tests to follow new syntax. --- tests/arab_to_roman.aer | 4 ++-- tests/callback_function.aer | 2 +- tests/debug_backtrace.aer | 6 +++--- tests/factorial_test.aer | 4 ++-- tests/hello_world.aer | 2 +- tests/load_module.aer | 2 +- tests/overloading_methods.aer | 6 +++--- tests/printf_test.aer | 16 ++++++++-------- tests/reference_test.aer | 4 ++-- tests/singleton_test.aer | 12 ++++++------ tests/tokenizer.aer | 14 +++++++------- tests/type_juggle.aer | 2 +- tests/unicode_characters.aer | 4 ++-- tests/utf8_variables.aer | 8 ++++---- 14 files changed, 43 insertions(+), 43 deletions(-) diff --git a/tests/arab_to_roman.aer b/tests/arab_to_roman.aer index 5bb0a6c..e47a349 100644 --- a/tests/arab_to_roman.aer +++ b/tests/arab_to_roman.aer @@ -1,6 +1,6 @@ class Program { - private function num2Roman(int $num) { + private string num2Roman(int $num) { int $n = intval($num); string $result = ''; int[] $lookup = array('M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, @@ -16,7 +16,7 @@ class Program { return $result; } - public function main() { + public void main() { print(' 7 => ' + $this->num2Roman(7) + "\n"); print(' 9 => ' + $this->num2Roman(9) + "\n"); print(' 11 => ' + $this->num2Roman(11) + "\n"); diff --git a/tests/callback_function.aer b/tests/callback_function.aer index f3b614d..f0992f0 100644 --- a/tests/callback_function.aer +++ b/tests/callback_function.aer @@ -1,6 +1,6 @@ class Program { - function main(string[] $args) { + void main(string[] $args) { callback $y = void() { callback $a = 'printf'; $a("I'm alive\n"); diff --git a/tests/debug_backtrace.aer b/tests/debug_backtrace.aer index f5bd94a..7cef860 100644 --- a/tests/debug_backtrace.aer +++ b/tests/debug_backtrace.aer @@ -1,10 +1,10 @@ class Program { - function main() { + void main() { $this->b($this->a('First A'), $this->a('Second A'), $this->a('Third A')); } - function a(string $p) { + string a(string $p) { mixed[] $backtrace = debug_backtrace(); if(isset($backtrace[0]['args'])) { var_export($backtrace[0]['args']); @@ -14,7 +14,7 @@ class Program { return $p; } - function b(string $p1, string $p2, string $p3) { + void b(string $p1, string $p2, string $p3) { print("$p1, $p2, $p3"); } diff --git a/tests/factorial_test.aer b/tests/factorial_test.aer index f064e5c..e99b87a 100644 --- a/tests/factorial_test.aer +++ b/tests/factorial_test.aer @@ -1,13 +1,13 @@ class Program { - function factorial(int $num) { + int factorial(int $num) { if($num == 0 || $num == 1) return 1; else return $num * $this->factorial($num - 1); } - function main() { + void main() { int $num = 7; print('Factorial of ', $num, ' is ', $this->factorial($num), '.'); } diff --git a/tests/hello_world.aer b/tests/hello_world.aer index 83c13b3..e8ced87 100644 --- a/tests/hello_world.aer +++ b/tests/hello_world.aer @@ -1,6 +1,6 @@ class Program { - public function main() { + public void main() { print('Hello world!'); } diff --git a/tests/load_module.aer b/tests/load_module.aer index d2ad4ef..09a1f32 100644 --- a/tests/load_module.aer +++ b/tests/load_module.aer @@ -1,5 +1,5 @@ final class Program { - function main() { + void main() { var_dump(function_exists('dummy_function')); var_dump(import('dummy')); var_dump(function_exists('dummy_function')); diff --git a/tests/overloading_methods.aer b/tests/overloading_methods.aer index cc45c09..aa2bfff 100644 --- a/tests/overloading_methods.aer +++ b/tests/overloading_methods.aer @@ -1,14 +1,14 @@ class Program { - function count(int $a, int $b) { + void count(int $a, int $b) { print("Counting 2 integers: $a + $b = ", $a + $b, "\n"); } - function count(float $a, float $b) { + void count(float $a, float $b) { print("Counting 2 floats: $a + $b = ", $a + $b, "\n"); } - function main() { + void main() { $this->count(4.3, 5.7); $this->count(6, 4); } diff --git a/tests/printf_test.aer b/tests/printf_test.aer index e839044..a5f802c 100644 --- a/tests/printf_test.aer +++ b/tests/printf_test.aer @@ -1,16 +1,16 @@ class Program { - private $s = 'monkey'; - private $t = 'many monkeys'; - private $n = 43951789; - private $u = -43951789; - private $c = 65; + private string $s = 'monkey'; + private string $t = 'many monkeys'; + private int $n = 43951789; + private int $u = -43951789; + private char $c = 65; - public function main() { + public void main() { $this->testMonkey(); $this->testNumbers(); } - private function testMonkey() { + private void testMonkey() { printf("[%s]\n", $this->s); printf("[%10s]\n", $this->s); printf("[%-10s]\n", $this->s); @@ -19,7 +19,7 @@ class Program { printf("[%10.10s]\n", $this->t); } - private function testNumbers() { + private void testNumbers() { printf("%%b = '%b'\n", $this->n); printf("%%c = '%c'\n", $this->c); printf("%%d = '%d'\n", $this->n); diff --git a/tests/reference_test.aer b/tests/reference_test.aer index 09073ac..6a04776 100644 --- a/tests/reference_test.aer +++ b/tests/reference_test.aer @@ -1,10 +1,10 @@ class Program { - function add_by_ref(int &$val) { + void add_by_ref(int &$val) { $val += 7; } - function main() { + void main() { int $num = 7; $this->add_by_ref($num); var_dump($num); diff --git a/tests/singleton_test.aer b/tests/singleton_test.aer index eb16bfa..4e6ab85 100644 --- a/tests/singleton_test.aer +++ b/tests/singleton_test.aer @@ -1,11 +1,11 @@ final class Test { - private $value; + private int $value; - private function __construct() { + private void __construct() { } /* This is singleton */ - public function getInstance() { + public object getInstance() { static object $instance; if(!$instance) { $instance = new Test(); @@ -13,17 +13,17 @@ final class Test { return $instance; } - public function get() { + public int get() { return $this->value; } - public function set(int $value = 0) { + public int set(int $value = 0) { $this->value = $value; } } final class Program { - public function main() { + public void main() { object $testA = Test::getInstance(); $testA->set(5); object $testB = Test::getInstance(); diff --git a/tests/tokenizer.aer b/tests/tokenizer.aer index 1393c71..7de9338 100644 --- a/tests/tokenizer.aer +++ b/tests/tokenizer.aer @@ -1,21 +1,21 @@ class StringTokenizer { - private $token; - private $delim; + private string $token; + private string $delim; - public function __construct(string $str, string $delim = ' ') { + public void __construct(string $str, string $delim = ' ') { $this->token = strtok($str, $delim); $this->delim = $delim; } - public function __destruct() { + public void __destruct() { unset($this); } - public function hasMoreTokens() { + public bool hasMoreTokens() { return ($this->token !== false); } - public function nextToken() { + public string nextToken() { string $current = $this->token; $this->token = strtok($this->delim); return $current; @@ -24,7 +24,7 @@ class StringTokenizer { } class Program { - function main() { + void main() { string $str = "This is:@\t\n a TEST!"; string $delim = " !@:\t\n"; object $st = new StringTokenizer($str, $delim); diff --git a/tests/type_juggle.aer b/tests/type_juggle.aer index 88a5b0b..d4f920c 100644 --- a/tests/type_juggle.aer +++ b/tests/type_juggle.aer @@ -1,6 +1,6 @@ class Program { - function main() { + void main() { mixed $foo; $foo = '0'; var_dump($foo); diff --git a/tests/unicode_characters.aer b/tests/unicode_characters.aer index 437fd87..f68cc19 100644 --- a/tests/unicode_characters.aer +++ b/tests/unicode_characters.aer @@ -1,6 +1,6 @@ class Unicode { - public function unicon(string $str, bool $to_uni = true) { + public string unicon(string $str, bool $to_uni = true) { string $cpp; string[] $cp = array('А' => 'А', 'а' => 'а', "Б" => "Б", "б" => "б", @@ -50,7 +50,7 @@ class Unicode { final class Program { - public function main() { + public void main() { object $unicode = new Unicode(); var_dump($unicode->unicon("ИфйжБЦ")); } diff --git a/tests/utf8_variables.aer b/tests/utf8_variables.aer index fdd7aca..7077546 100644 --- a/tests/utf8_variables.aer +++ b/tests/utf8_variables.aer @@ -1,18 +1,18 @@ class Program { - private $概要 = "AerScript Interpreter"; + private string $概要 = "AerScript Interpreter"; - public function main() { + public void main() { $this->ダウンロード(); var_dump($this->概要); var_dump($this->isUTF8('hello')); var_dump($this->isUTF8("すが、基本的な使い方は単純です。かしながら使い方を身につけていきましょう")); } - private function ダウンロード(){ + private void ダウンロード(){ print($this->概要 + "\n"); } - private function isUTF8(string $str) { + private bool isUTF8(string $str) { int $b = 0; int $c = 0; int $bits = 0;