OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // Tests of interceptors. | 5 // Tests of interceptors. |
6 | 6 |
7 library interceptors_tests; | 7 library interceptors_tests; |
8 | 8 |
9 import 'js_backend_cps_ir.dart'; | 9 import 'js_backend_cps_ir.dart'; |
10 | 10 |
11 const List<TestEntry> tests = const [ | 11 const List<TestEntry> tests = const [ |
12 const TestEntry(""" | 12 const TestEntry(""" |
13 main() { | 13 main() { |
14 var g = 1; | 14 var g = 1; |
15 | 15 |
16 var x = g + 3; | 16 var x = g + 3; |
17 print(x); | 17 print(x); |
18 }""", | 18 }""", |
19 r""" | 19 r""" |
20 function() { | 20 function() { |
21 P.print(4); | 21 var v0 = H.S(4); |
| 22 if (typeof dartPrint == "function") |
| 23 dartPrint(v0); |
| 24 else if (typeof console == "object" && typeof console.log != "undefined") |
| 25 console.log(v0); |
| 26 else if (!(typeof window == "object")) { |
| 27 if (!(typeof print == "function")) |
| 28 throw "Unable to print message: " + String(v0); |
| 29 print(v0); |
| 30 } |
22 }"""), | 31 }"""), |
23 const TestEntry(""" | 32 const TestEntry(""" |
24 main() { | 33 main() { |
25 var l = ['hest', ['h', 'e', 's', 't']]; | 34 var l = ['hest', ['h', 'e', 's', 't']]; |
26 print(l.length); | 35 print(l.length); |
27 for (int i = 0; i < l.length; i++) { | 36 for (int i = 0; i < l.length; i++) { |
28 var x = l[i]; | 37 var x = l[i]; |
29 for (int j = 0; j < x.length; j++) { | 38 for (int j = 0; j < x.length; j++) { |
30 print(x[j]); | 39 print(x[j]); |
31 } | 40 } |
32 } | 41 } |
33 }""", | 42 }""", |
34 r""" | 43 r""" |
35 function() { | 44 function() { |
36 var l = ["hest", ["h", "e", "s", "t"]], i = 0, x, j; | 45 var l = ["hest", ["h", "e", "s", "t"]], i = 0, x, j; |
37 for (P.print(2); i < 2; i = i + 1) { | 46 for (P.print(2); i < 2; i = i + 1) { |
38 x = l[i]; | 47 x = l[i]; |
39 for (j = 0; j < x.length; j = j + 1) | 48 for (j = 0; j < x.length; j = j + 1) |
40 P.print(x[j]); | 49 P.print(x[j]); |
41 } | 50 } |
42 }"""), | 51 }"""), |
43 ]; | 52 ]; |
44 | 53 |
45 | 54 |
46 void main() { | 55 void main() { |
47 runTests(tests); | 56 runTests(tests); |
48 } | 57 } |
OLD | NEW |