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 P.print(4); |
22 return null; | |
23 }"""), | 22 }"""), |
24 const TestEntry(""" | 23 const TestEntry(""" |
25 main() { | 24 main() { |
26 var l = ['hest', ['h', 'e', 's', 't']]; | 25 var l = ['hest', ['h', 'e', 's', 't']]; |
27 print(l.length); | 26 print(l.length); |
28 for (int i = 0; i < l.length; i++) { | 27 for (int i = 0; i < l.length; i++) { |
29 var x = l[i]; | 28 var x = l[i]; |
30 for (int j = 0; j < x.length; j++) { | 29 for (int j = 0; j < x.length; j++) { |
31 print(x[j]); | 30 print(x[j]); |
32 } | 31 } |
33 } | 32 } |
34 }""", | 33 }""", |
35 r""" | 34 r""" |
36 function() { | 35 function() { |
37 var l = ["hest", ["h", "e", "s", "t"]], i = 0, x, j; | 36 var l = ["hest", ["h", "e", "s", "t"]], i = 0, x, j; |
38 P.print(J.getInterceptor$as(l).get$length(l)); | 37 P.print(J.getInterceptor$as(l).get$length(l)); |
39 while (i < J.getInterceptor$as(l).get$length(l)) { | 38 while (i < J.getInterceptor$as(l).get$length(l)) { |
40 x = J.getInterceptor$as(l).$index(l, i); | 39 x = J.getInterceptor$as(l).$index(l, i); |
41 j = 0; | 40 j = 0; |
42 while (j < J.getInterceptor$as(x).get$length(x)) { | 41 while (j < J.getInterceptor$as(x).get$length(x)) { |
43 P.print(J.getInterceptor$as(x).$index(x, j)); | 42 P.print(J.getInterceptor$as(x).$index(x, j)); |
44 j = j + 1; | 43 j = j + 1; |
45 } | 44 } |
46 i = i + 1; | 45 i = i + 1; |
47 } | 46 } |
48 return null; | |
49 }"""), | 47 }"""), |
50 ]; | 48 ]; |
51 | 49 |
52 | 50 |
53 void main() { | 51 void main() { |
54 runTests(tests); | 52 runTests(tests); |
55 } | 53 } |
OLD | NEW |