new parameter -s textonly
[swftools.git] / ok / reconcile.as
1 package {
2         import flash.display.MovieClip;
3         import flash.utils.ByteArray;
4
5         public class Main extends flash.display.MovieClip {
6
7             // test whether local variables with default value "null"
8             // will be coerced to their object
9             public function test1() {
10                 var dataBuffer:Array;
11                 while(true) {
12                     dataBuffer = new Array();
13                     if(dataBuffer)
14                         break;
15                 }
16                 trace("ok 1/9");
17             }
18
19             public function test2() {
20                 var output:String = "";
21                 while(output.length<1) {
22                     output += "abc".charAt(0);
23                 }
24                 trace("ok 2/9");
25             }
26
27             public function test3() {
28                 var k:uint;
29
30                 while(true) {
31                     for (var k:uint = 0; k < 4; k++) {
32                     }
33                     break;
34                 }
35                 trace("ok 3/9");
36             }
37
38             public var b:Boolean = false;
39
40             public function test4() {
41                 var x:int;
42                 var y:uint;
43                 if(b) {
44                     x = x+y;
45                     y = y+x;
46                 }
47                 trace("ok 4/9");
48             }
49             public function test5() {
50                 var x:int;
51                 var y:uint;
52                 var z:int;
53                 if(b) {
54                     x = x*y;
55                     z = x*z;
56                 }
57                 trace("ok 5/9");
58             }
59             public function test6() {
60                 var i:int = b?3.0:3;
61                 var j:uint = b?3:"abc";
62                 trace("ok 6/9");
63             }
64             public function test7() {
65                 var j:Number = 0;
66                 if(b) {
67                     j += 8;
68                 }
69                 trace("ok 7/9");
70             }
71             public function s():String {
72                 return "x";
73             }
74             public function test8() {
75                 var x:String = "abcd";
76
77                 var i:String = "test";
78                 // test return types of system libraries
79                 if(!b) {
80                     i = x.charAt(0);
81                 }
82                 var a = "test";
83                 // test return types of system libraries
84                 if(!b) {
85                     a = x.charAt(0);
86                 }
87
88                 // ...and local functions
89                 if(!b) {
90                     i = s();
91                 }
92                 trace("ok 8/9");
93             }
94             
95             public function test_add() {
96                 var i:int = 3;
97                 var s:String = "4";
98                 var any1 = "any1";
99                 var any2 = "any2";
100                 var xml:XML = <test/>
101                 var xmllist:XMLList = XMLList(<test/>)
102                 var d1:Date = new Date();
103                 var d2:Date = new Date();
104                 var array1:Array = [1];
105                 var array2:Array = [1,2];
106
107                 /* int+String */
108                 var z1a:Object;
109                 var z1b:String;
110                 if(b) {
111                     z1a = i+s;
112                     z1b = i+s;
113                 }
114
115                 /* String+int */
116                 var z2a:Object;
117                 var z2b:String;
118                 if(b) {
119                     z2a = s+i;
120                     z2b = s+i;
121                 }
122
123                 /* any+any */
124                 var z3a:*;
125                 var z3b:Object;
126                 if(b) {
127                     z3a = any1+any2;
128                     z3b = any1+any2;
129                 }
130                 
131                 /* any+String */
132                 var z4a:Object;
133                 var z4b:*;
134                 if(b) {
135                     z4a = any1+s;
136                     z4b = any1+s;
137                 }
138
139                 /* xml+xmllist */
140                 var z5a:Object;
141                 var z5b:XMLList;
142                 if(b) {
143                     z5a = xml+xmllist;
144                     z5b = xml+xmllist;
145                 }
146
147                 /* xmllist+xml */
148                 var z6:Object;
149                 if(b) {
150                     z6 = xmllist+xml;
151                 }
152                 
153                 /* xml+any */
154                 var z7a:*;
155                 var z7b:XMLList;
156                 if(b) {
157                     z7a = xml+any1;
158                     z7b = xml+any1;
159                 }
160                 
161                 /* date+date */
162                 var z8a:Object;
163                 var z8b:String;
164                 if(b) {
165                     z8a = d1+d2;
166                     z8b = d1+d2;
167                 }
168                 
169                 /* date+any */
170                 var z9a:Object;
171                 var z9b:String;
172                 if(b) {
173                     z9a = d1+any1;
174                     z9b = d1+any1;
175                 }
176                 
177                 /* any+date */
178                 var z10a:Object;
179                 var z10b:*;
180                 if(b) {
181                     z10a = any1+d1;
182                     z10b = any1+d1;
183                 }
184                 
185                 /* array+array */
186                 var z11a:Object;
187                 var z11b:Array;
188                 if(b) {
189                     z11a = array1+array2;
190                     z11b = array1+array2;
191                 }
192                 trace("ok 9/9");
193             }
194
195             public function Main() {
196                 test1();
197                 test2();
198                 test3();
199                 test4();
200                 test5();
201                 test6();
202                 test7();
203                 test8();
204                 test_add();
205             
206                 trace("[exit]");
207             }
208         }
209 }