Aer/tests/printf_test.aer

40 lines
1013 B
Plaintext
Raw Permalink Normal View History

class Program {
2019-03-17 19:48:52 +01:00
private string $s = 'monkey';
private string $t = 'many monkeys';
private int $n = 43951789;
private int $u = -43951789;
private char $c = 65;
2018-08-07 17:16:28 +02:00
2019-03-17 19:48:52 +01:00
public void main() {
2018-08-07 17:16:28 +02:00
$this->testMonkey();
$this->testNumbers();
}
2019-03-17 19:48:52 +01:00
private void testMonkey() {
2018-08-07 17:16:28 +02:00
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);
}
2019-03-17 19:48:52 +01:00
private void testNumbers() {
2018-08-07 17:16:28 +02:00
printf("%%b = '%b'\n", $this->n);
printf("%%c = '%c'\n", $this->c);
2019-04-08 10:32:31 +02:00
printf("%%d = '%d'\n", $this->c);
2018-08-07 17:16:28 +02:00
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);
}
}