f649b5d0cc7b9da1d13ea7d9423128b3cd313f8b
[yaffs-website] / vendor / nikic / php-parser / test / code / prettyPrinter / expr / literals.test
1 Literals
2 -----
3 <?php
4
5 // magic constants
6 __LINE__;
7 __FILE__;
8 __DIR__;
9 __FUNCTION__;
10 __CLASS__;
11 __TRAIT__;
12 __METHOD__;
13 __NAMESPACE__;
14
15 // not actually literals, but close
16 null;
17 true;
18 false;
19 NULL;
20 TRUE;
21 FALSE;
22
23 // integers (normalized to decimal)
24 0;
25 11;
26 011;
27 0x11;
28 0b11;
29
30 // floats (normalized to ... something)
31 0.;
32 .0;
33 0.0;
34 0e1000;
35 1.0;
36 1e100;
37 1e1000;
38 1E-100;
39 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000;
40 378282246310005.0;
41 10000000000000002.0;
42
43 // strings (single quoted)
44 'a';
45 'a
46 b';
47 'a\'b';
48 'a\b';
49 'a\\';
50
51 // strings (double quoted)
52 "a";
53 "a\nb";
54 "a'b";
55 "a\b";
56 "$a";
57 "a$b";
58 "$a$b";
59 "$a $b";
60 "a${b}c";
61 "a{$b}c";
62 "a$a[b]c";
63 "\{$A}";
64 "\{ $A }";
65 "\\{$A}";
66 "\\{ $A }";
67 "{$$A}[B]";
68 "$$A[B]";
69
70 // make sure indentation doesn't mess anything up
71 function foo()
72 {
73     "a\nb";
74     'a
75 b';
76     'a
77     b';
78 }
79
80 // shell exec (similar to double quoted string)
81 `foo`;
82 `foo$a`;
83 `foo{$a}bar`;
84 `\`\'\"`;
85 -----
86 // magic constants
87 __LINE__;
88 __FILE__;
89 __DIR__;
90 __FUNCTION__;
91 __CLASS__;
92 __TRAIT__;
93 __METHOD__;
94 __NAMESPACE__;
95 // not actually literals, but close
96 null;
97 true;
98 false;
99 NULL;
100 TRUE;
101 FALSE;
102 // integers (normalized to decimal)
103 0;
104 11;
105 011;
106 0x11;
107 0b11;
108 // floats (normalized to ... something)
109 0.0;
110 0.0;
111 0.0;
112 0.0;
113 1.0;
114 1.0E+100;
115 \INF;
116 1.0E-100;
117 1.0E+84;
118 378282246310005.0;
119 10000000000000002.0;
120 // strings (single quoted)
121 'a';
122 'a
123 b';
124 'a\'b';
125 'a\\b';
126 'a\\';
127 // strings (double quoted)
128 "a";
129 "a\nb";
130 "a'b";
131 "a\\b";
132 "{$a}";
133 "a{$b}";
134 "{$a}{$b}";
135 "{$a} {$b}";
136 "a{$b}c";
137 "a{$b}c";
138 "a{$a['b']}c";
139 "\\{{$A}}";
140 "\\{ {$A} }";
141 "\\{$A}";
142 "\\{ {$A} }";
143 "{${$A}}[B]";
144 "\${$A['B']}";
145 // make sure indentation doesn't mess anything up
146 function foo()
147 {
148     "a\nb";
149     'a
150 b';
151     'a
152     b';
153 }
154 // shell exec (similar to double quoted string)
155 `foo`;
156 `foo{$a}`;
157 `foo{$a}bar`;
158 `\`\\'\\"`;