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