diff --git a/tests/printf_test.aer b/tests/printf_test.aer new file mode 100644 index 0000000..500cab9 --- /dev/null +++ b/tests/printf_test.aer @@ -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(); \ No newline at end of file diff --git a/tests/printf_test.exp b/tests/printf_test.exp new file mode 100644 index 0000000..a1d8c18 --- /dev/null +++ b/tests/printf_test.exp @@ -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' diff --git a/tests/type_juggle.aer b/tests/type_juggle.aer new file mode 100644 index 0000000..0acbbbd --- /dev/null +++ b/tests/type_juggle.aer @@ -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(); diff --git a/tests/type_juggle.exp b/tests/type_juggle.exp new file mode 100644 index 0000000..42e6c4b --- /dev/null +++ b/tests/type_juggle.exp @@ -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 '')