Browse Source

Add more tests

pull/44/head
Rafal Kupiec 2 years ago
parent
commit
c419b8605d
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
4 changed files with 95 additions and 0 deletions
  1. +40
    -0
      tests/printf_test.aer
  2. +19
    -0
      tests/printf_test.exp
  3. +27
    -0
      tests/type_juggle.aer
  4. +9
    -0
      tests/type_juggle.exp

+ 40
- 0
tests/printf_test.aer View File

@ -0,0 +1,40 @@
class Main {
private $s = 'monkey';
private $t = 'many monkeys';
private $n = 43951789;
private $u = -43951789;
private $c = 65;
public function __construct() {
$this->testMonkey();
$this->testNumbers();
}
private function testMonkey() {
printf("[%s]\n", $this->s);
printf("[%10s]\n", $this->s);
printf("[%-10s]\n", $this->s);
printf("[%010s]\n", $this->s);
printf("[%'#10s]\n", $this->s);
printf("[%10.10s]\n", $this->t);
}
private function testNumbers() {
printf("%%b = '%b'\n", $this->n);
printf("%%c = '%c'\n", $this->c);
printf("%%d = '%d'\n", $this->n);
printf("%%e = '%e'\n", $this->n);
printf("%%u = '%u'\n", $this->n);
printf("%%u = '%u'\n", $this->u);
printf("%%f = '%f'\n", $this->n);
printf("%%o = '%o'\n", $this->n);
printf("%%s = '%s'\n", $this->n);
printf("%%x = '%x'\n", $this->n);
printf("%%X = '%X'\n", $this->n);
printf("%%+d = '%+d'\n", $this->n);
printf("%%+d = '%+d'\n", $this->u);
}
}
new Main();

+ 19
- 0
tests/printf_test.exp View File

@ -0,0 +1,19 @@
[monkey]
[ monkey]
[monkey ]
[0000monkey]
[####monkey]
[many monke]
%b = '10100111101010011010101101'
%c = 'A'
%d = '43951789'
%e = '4.395179e+07'
%u = '43951789'
%u = '43951789'
%f = '43951789.000000'
%o = '247523255'
%s = '43951789'
%x = '29ea6ad'
%X = '29EA6AD'
%+d = '+43951789'
%+d = '-43951789'

+ 27
- 0
tests/type_juggle.aer View File

@ -0,0 +1,27 @@
class Main {
function __construct() {
$foo = '0';
var_dump($foo);
$foo += 2;
var_dump($foo);
$foo = 1;
var_dump($foo);
$foo += 1.3;
var_dump($foo);
$foo = 5 + "10 Little Piggies";
var_dump($foo);
$foo = 5 + 10;
var_dump($foo);
$foo = 'car';
$foo[0] = 'b';
var_dump($foo);
$foo = 10;
$foo = (bool) $foo;
var_dump($foo);
$foo = '';
var_dump($foo);
}
}
new Main();

+ 9
- 0
tests/type_juggle.exp View File

@ -0,0 +1,9 @@
string(1 '0')
string(2 '02')
int(1)
float(2.3)
string(18 '510 Little Piggies')
int(15)
string(3 'bar')
bool(TRUE)
string(0 '')

Loading…
Cancel
Save