Bug 623379: runtests: Check for java binary before asc invokes (r=fklockii)
[tamarin-stm.git] / eval / smoketest.as
blobcb54b77d0c299f98be101c03f1c85704101da5ab
1 /* -*- Mode: Java; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */
2 /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is [Open Source Virtual Machine.].
18 * The Initial Developer of the Original Code is
19 * Adobe System Incorporated.
20 * Portions created by the Initial Developer are Copyright (C) 2008
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s):
24 * Adobe AS3 Team
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 print(eval("print('hello, nested world'); 37"))
41 print("hello, world");
42 print(9 % 4);
43 print({ "foo": 10, bar: 20 });
44 print({ "foo": 10, bar: 20 }.foo);
45 print({ "foo": 10, bar: 20 }.bar);
46 print(["a","b",,"c",,].length); // should be 5
47 print(["a","b",,"c",,]);
48 print(/a*b/g);
49 var v = "v!";
50 print(v);
51 var x = 10;
52 print(x++);
53 print(++x);
54 function f() {
55 function g() { print("holy smokes, batman!"); }
56 g();
57 return "zappa";
59 print(f());
60 var x = 10;
61 if (x < 5)
62 print("true");
63 else
64 print("false");
65 for ( var i=0 ; i < 10 ; i++ )
66 print(i);
67 print("done");
68 print(w);
69 var w = "outer";
70 function g() { var w = "inner"; }
71 g();
72 print(w);
73 print(delete w);
74 print(typeof w);
76 function h() { print("first"); }
77 h();
78 function h() { print("second"); }
79 h();
80 function zappa(x, y) { return x + y; }
81 print(zappa("hello", "there"));
82 print(x);
83 print(x *= 5);
84 print(x);
85 var obj = ["a"];
86 print(obj.toString());
87 print(obj["toString"]());
88 print(new Array(1,2,3));
89 function ww() {
90 return "" + this.x + "," + this.y
92 function c(x) {
93 this.x = x;
94 this.toString = ww;
96 c.prototype = { y: 20 };
97 print(new c(10));
98 var zz = function (x) { return x }
99 print(zz("hello"));
100 var uu = "nothing special"
101 var yy = function uu(x) { return x }
102 print(yy("hello"))
103 print(uu)
105 var obj = ["a","b","c"]
106 for ( i in obj)
107 print(i);
108 for ( var i=17 in [] )
109 print(i);
110 print(i);
111 for ( var i=17 in obj )
112 print(i + "," + obj[i]);
114 try {
115 obj = null;
116 print("Should happen");
118 catch (e) {
119 print("Should not happen");
122 try {
123 throw "Foo";
124 print("Should not happen");
126 catch (e) {
127 print("Should happen with foo: " + e);
129 try {
130 print("Number 1");
132 finally {
133 print("Number 2");
135 try {
136 throw "foo";
138 catch (e) {
139 print(e);
141 finally {
142 print("number 3");
145 print("Got to end");
146 function abba() {
147 print(arguments);
150 abba(1,2,3,4)
151 for each ( var i in [1,2,3])
152 print(i);
154 include "smoketest2.as";
155 include "smoketest2.as"
157 function typed1(x: int): void {
158 var v : String = "foo";
159 return;
162 print("hello".split("ll"));
164 x = 0;
165 loop:
166 while(x < 10) {
167 x++;
168 continue loop;
169 print("not here");
172 print(x);
174 for ( x=0 ; x < 1 ; x++ )
175 for each ( i in [1,2,3] )
176 print(i);
178 var object = { fun: function() { return this.valueOf(); }, valueOf: function () { return this.value }, value: 37 };
179 print(object.fun());
180 function t() {
181 var a = 1;
182 with ({a: 2}) {
183 function f() { return a }
185 return f();
187 print(t());
189 print(1.7976931348623145e308);
190 print(Number.MAX_VALUE);
192 print(0x0);
193 print(0x12);
195 print(/\u0041/g);
196 print(/\u0041/.exec("A").length);
197 print("\u0041");
198 print(/\u004g/);
200 function p() {
201 function g() { return this }
202 var o = g()
203 return o == this
205 print(p())
206 try {
207 print(eval("function () { broken broken broken"));
209 catch (e) {
210 print(e);
212 print(parseInt(341, 8).toString(16));
213 var f = function (x) { print(arguments); return arguments.callee; }
214 print(f(10));
216 function container() {
217 var v = function () { print("hello"); }
218 v.toString = Object.prototype.toString;
219 print(v);
221 container();
223 function rest(x, ...rest) {
224 print(x);
225 print(rest);
227 rest(1,2,3,4);
229 order =
230 <order>
231 <customer>
232 <name>John Smith</name>
233 </customer>
234 <item id="1">
235 <description>Big Screen Television</description>
236 <price>1299.99</price>
237 </item>
238 <item id="2">
239 <description>DVD Player</description>
240 <price>399.99</price>
241 </item>
242 </order>;
243 print(order);
245 var xml7 = <><c q='1'>"quotes"</c><c q='2'>&#x7B;curly brackets&#x7D;</c></>;
246 print(xml7);
248 e = <employees>
249 <employee id="0"><fname>John</fname><age>20</age></employee>
250 <employee id="1"><fname>Sue</fname><age>30</age></employee>
251 </employees>;
254 correct = <employee id="0"><fname>John</fname><age>20</age></employee>;
256 john = e.employee.(fname == "John");
258 print(john);
260 x1 =
261 <alpha attr1="value1" attr2="value2">
262 <bravo>
264 <charlie>two</charlie>
265 </bravo>
266 </alpha>;
268 print("---");
269 print(x1..*);
270 print("---");
272 // fast switches - this code triggers fast switch generation on 2009-03-03, at least.
273 // would be good to verify that it continues to do so...
275 // output should be 5 4 4 again default 2 1 2 0
277 for ( var i=5 ; i >= 0 ; i-- ) {
278 switch (i) {
279 case 0: print("0"); break;
280 case 1: print("1"); // no break
281 case 2: print("2"); break;
282 case 1: print("3"); break;
283 case 4: print("4");
284 print("4 again"); break;
285 case 5: print("5"); break;
286 default: print("default"); break;
290 // -- Nothing new beyond this line! ----------------------------------------------------------
292 print("");
293 print("SMOKETEST DONE!");