1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-27 04:14:44 +01:00
PHP-Parser/test/code/prettyPrinter/literals.test
Nikita Popov 8b64195cf2 Try .17G print if .16G is not enough
This should be enough for all cases, because: A double has 53 bits
of mantissa (including the implicit 1 bit), which is 53*ln(2)/ln(10)
= 15.95 decimal digits. However the leading decimal digit may encode
less than the usual 3.32 bits, which will push this over the edge to
requiring 17 decimal digits.
2015-05-02 11:48:55 +02:00

156 lines
1.7 KiB
Plaintext

Literals
-----
<?php
// magic constants
__LINE__;
__FILE__;
__DIR__;
__FUNCTION__;
__CLASS__;
__TRAIT__;
__METHOD__;
__NAMESPACE__;
// not actually literals, but close
null;
true;
false;
NULL;
TRUE;
FALSE;
// integers (normalized to decimal)
0;
11;
011;
0x11;
0b11;
// floats (normalized to ... something)
0.;
.0;
0.0;
0e1000;
1.0;
1e100;
1e1000;
1E-100;
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000;
378282246310005.0;
10000000000000002.0;
// strings (normalized to single quoted)
'a';
'a
b';
"a";
"a\nb";
'a\'b';
"a'b";
"a\b";
<<<'STR'
a\nb$a
{$b}
STR;
// strings (normalized to double quoted)
"$a";
"a$b";
"$a$b";
"$a $b";
"a${b}c";
"a{$b}c";
"a$a[b]c";
"\{$A}";
"\{ $A }";
"\\{$A}";
"\\{ $A }";
"{$$A}[B]";
"$$A[B]";
<<<STR
a\nb$a\n{$b}
STR;
// make sure indentation doesn't mess anything up
function foo()
{
"a\nb";
'a
b';
'a
b';
}
-----
// magic constants
__LINE__;
__FILE__;
__DIR__;
__FUNCTION__;
__CLASS__;
__TRAIT__;
__METHOD__;
__NAMESPACE__;
// not actually literals, but close
null;
true;
false;
NULL;
TRUE;
FALSE;
// integers (normalized to decimal)
0;
11;
9;
17;
3;
// floats (normalized to ... something)
0.0;
0.0;
0.0;
0.0;
1.0;
1.0E+100;
INF;
1.0E-100;
1.0E+84;
378282246310005.0;
10000000000000002.0;
// strings (normalized to single quoted)
'a';
'a
b';
'a';
'a
b';
'a\'b';
'a\'b';
'a\\b';
'a\\nb$a
{$b}';
// strings (normalized to double quoted)
"{$a}";
"a{$b}";
"{$a}{$b}";
"{$a} {$b}";
"a{$b}c";
"a{$b}c";
"a{$a['b']}c";
"\\{{$A}}";
"\\{ {$A} }";
"\\{$A}";
"\\{ {$A} }";
"{${$A}}[B]";
"\${$A['B']}";
"a\nb{$a}\n{$b}";
// make sure indentation doesn't mess anything up
function foo()
{
'a
b';
'a
b';
'a
b';
}