Update tests to follow new syntax.
The build has failed. Details

This commit is contained in:
Rafal Kupiec 2019-03-17 19:48:52 +01:00
parent c26f8cd777
commit ff73690111
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
14 changed files with 43 additions and 43 deletions

View File

@ -1,6 +1,6 @@
class Program { class Program {
private function num2Roman(int $num) { private string num2Roman(int $num) {
int $n = intval($num); int $n = intval($num);
string $result = ''; string $result = '';
int[] $lookup = array('M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, int[] $lookup = array('M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400,
@ -16,7 +16,7 @@ class Program {
return $result; return $result;
} }
public function main() { public void main() {
print(' 7 => ' + $this->num2Roman(7) + "\n"); print(' 7 => ' + $this->num2Roman(7) + "\n");
print(' 9 => ' + $this->num2Roman(9) + "\n"); print(' 9 => ' + $this->num2Roman(9) + "\n");
print(' 11 => ' + $this->num2Roman(11) + "\n"); print(' 11 => ' + $this->num2Roman(11) + "\n");

View File

@ -1,6 +1,6 @@
class Program { class Program {
function main(string[] $args) { void main(string[] $args) {
callback $y = void() { callback $y = void() {
callback $a = 'printf'; callback $a = 'printf';
$a("I'm alive\n"); $a("I'm alive\n");

View File

@ -1,10 +1,10 @@
class Program { class Program {
function main() { void main() {
$this->b($this->a('First A'), $this->a('Second A'), $this->a('Third A')); $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(); mixed[] $backtrace = debug_backtrace();
if(isset($backtrace[0]['args'])) { if(isset($backtrace[0]['args'])) {
var_export($backtrace[0]['args']); var_export($backtrace[0]['args']);
@ -14,7 +14,7 @@ class Program {
return $p; return $p;
} }
function b(string $p1, string $p2, string $p3) { void b(string $p1, string $p2, string $p3) {
print("$p1, $p2, $p3"); print("$p1, $p2, $p3");
} }

View File

@ -1,13 +1,13 @@
class Program { class Program {
function factorial(int $num) { int factorial(int $num) {
if($num == 0 || $num == 1) if($num == 0 || $num == 1)
return 1; return 1;
else else
return $num * $this->factorial($num - 1); return $num * $this->factorial($num - 1);
} }
function main() { void main() {
int $num = 7; int $num = 7;
print('Factorial of ', $num, ' is ', $this->factorial($num), '.'); print('Factorial of ', $num, ' is ', $this->factorial($num), '.');
} }

View File

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

View File

@ -1,5 +1,5 @@
final class Program { final class Program {
function main() { void main() {
var_dump(function_exists('dummy_function')); var_dump(function_exists('dummy_function'));
var_dump(import('dummy')); var_dump(import('dummy'));
var_dump(function_exists('dummy_function')); var_dump(function_exists('dummy_function'));

View File

@ -1,14 +1,14 @@
class Program { class Program {
function count(int $a, int $b) { void count(int $a, int $b) {
print("Counting 2 integers: $a + $b = ", $a + $b, "\n"); 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"); print("Counting 2 floats: $a + $b = ", $a + $b, "\n");
} }
function main() { void main() {
$this->count(4.3, 5.7); $this->count(4.3, 5.7);
$this->count(6, 4); $this->count(6, 4);
} }

View File

@ -1,16 +1,16 @@
class Program { class Program {
private $s = 'monkey'; private string $s = 'monkey';
private $t = 'many monkeys'; private string $t = 'many monkeys';
private $n = 43951789; private int $n = 43951789;
private $u = -43951789; private int $u = -43951789;
private $c = 65; private char $c = 65;
public function main() { public void main() {
$this->testMonkey(); $this->testMonkey();
$this->testNumbers(); $this->testNumbers();
} }
private function testMonkey() { private void testMonkey() {
printf("[%s]\n", $this->s); printf("[%s]\n", $this->s);
printf("[%10s]\n", $this->s); printf("[%10s]\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); printf("[%10.10s]\n", $this->t);
} }
private function testNumbers() { private void testNumbers() {
printf("%%b = '%b'\n", $this->n); printf("%%b = '%b'\n", $this->n);
printf("%%c = '%c'\n", $this->c); printf("%%c = '%c'\n", $this->c);
printf("%%d = '%d'\n", $this->n); printf("%%d = '%d'\n", $this->n);

View File

@ -1,10 +1,10 @@
class Program { class Program {
function add_by_ref(int &$val) { void add_by_ref(int &$val) {
$val += 7; $val += 7;
} }
function main() { void main() {
int $num = 7; int $num = 7;
$this->add_by_ref($num); $this->add_by_ref($num);
var_dump($num); var_dump($num);

View File

@ -1,11 +1,11 @@
final class Test { final class Test {
private $value; private int $value;
private function __construct() { private void __construct() {
} }
/* This is singleton */ /* This is singleton */
public function getInstance() { public object getInstance() {
static object $instance; static object $instance;
if(!$instance) { if(!$instance) {
$instance = new Test(); $instance = new Test();
@ -13,17 +13,17 @@ final class Test {
return $instance; return $instance;
} }
public function get() { public int get() {
return $this->value; return $this->value;
} }
public function set(int $value = 0) { public int set(int $value = 0) {
$this->value = $value; $this->value = $value;
} }
} }
final class Program { final class Program {
public function main() { public void main() {
object $testA = Test::getInstance(); object $testA = Test::getInstance();
$testA->set(5); $testA->set(5);
object $testB = Test::getInstance(); object $testB = Test::getInstance();

View File

@ -1,21 +1,21 @@
class StringTokenizer { class StringTokenizer {
private $token; private string $token;
private $delim; private string $delim;
public function __construct(string $str, string $delim = ' ') { public void __construct(string $str, string $delim = ' ') {
$this->token = strtok($str, $delim); $this->token = strtok($str, $delim);
$this->delim = $delim; $this->delim = $delim;
} }
public function __destruct() { public void __destruct() {
unset($this); unset($this);
} }
public function hasMoreTokens() { public bool hasMoreTokens() {
return ($this->token !== false); return ($this->token !== false);
} }
public function nextToken() { public string nextToken() {
string $current = $this->token; string $current = $this->token;
$this->token = strtok($this->delim); $this->token = strtok($this->delim);
return $current; return $current;
@ -24,7 +24,7 @@ class StringTokenizer {
} }
class Program { class Program {
function main() { void main() {
string $str = "This is:@\t\n a TEST!"; string $str = "This is:@\t\n a TEST!";
string $delim = " !@:\t\n"; string $delim = " !@:\t\n";
object $st = new StringTokenizer($str, $delim); object $st = new StringTokenizer($str, $delim);

View File

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

View File

@ -1,6 +1,6 @@
class Unicode { class Unicode {
public function unicon(string $str, bool $to_uni = true) { public string unicon(string $str, bool $to_uni = true) {
string $cpp; string $cpp;
string[] $cp = array('А' => 'А', 'а' => 'а', string[] $cp = array('А' => 'А', 'а' => 'а',
"Б" => "Б", "б" => "б", "Б" => "Б", "б" => "б",
@ -50,7 +50,7 @@ class Unicode {
final class Program { final class Program {
public function main() { public void main() {
object $unicode = new Unicode(); object $unicode = new Unicode();
var_dump($unicode->unicon("ИфйжБЦ")); var_dump($unicode->unicon("ИфйжБЦ"));
} }

View File

@ -1,18 +1,18 @@
class Program { class Program {
private $概要 = "AerScript Interpreter"; private string $概要 = "AerScript Interpreter";
public function main() { public void main() {
$this->ダウンロード(); $this->ダウンロード();
var_dump($this->概要); var_dump($this->概要);
var_dump($this->isUTF8('hello')); var_dump($this->isUTF8('hello'));
var_dump($this->isUTF8("すが、基本的な使い方は単純です。かしながら使い方を身につけていきましょう")); var_dump($this->isUTF8("すが、基本的な使い方は単純です。かしながら使い方を身につけていきましょう"));
} }
private function ダウンロード(){ private void ダウンロード(){
print($this->概要 + "\n"); print($this->概要 + "\n");
} }
private function isUTF8(string $str) { private bool isUTF8(string $str) {
int $b = 0; int $b = 0;
int $c = 0; int $c = 0;
int $bits = 0; int $bits = 0;