Browse Source

Update tests to follow new syntax.

pull/50/head
Rafal Kupiec 3 years ago
parent
commit
ff73690111
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
  1. 4
      tests/arab_to_roman.aer
  2. 2
      tests/callback_function.aer
  3. 6
      tests/debug_backtrace.aer
  4. 4
      tests/factorial_test.aer
  5. 2
      tests/hello_world.aer
  6. 2
      tests/load_module.aer
  7. 6
      tests/overloading_methods.aer
  8. 16
      tests/printf_test.aer
  9. 4
      tests/reference_test.aer
  10. 12
      tests/singleton_test.aer
  11. 14
      tests/tokenizer.aer
  12. 2
      tests/type_juggle.aer
  13. 4
      tests/unicode_characters.aer
  14. 8
      tests/utf8_variables.aer

4
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");

2
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");

6
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");
}

4
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), '.');
}

2
tests/hello_world.aer

@ -1,6 +1,6 @@
class Program {
public function main() {
public void main() {
print('Hello world!');
}

2
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'));

6
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);
}

16
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);

4
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);

12
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();

14
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);

2
tests/type_juggle.aer

@ -1,6 +1,6 @@
class Program {
function main() {
void main() {
mixed $foo;
$foo = '0';
var_dump($foo);

4
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("ИфйжБЦ"));
}

8
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;

Loading…
Cancel
Save