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 operators. | 5 // Tests of operators. |
6 | 6 |
7 library operators_tests; | 7 library operators_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("main() { return true ? 42 : 'foo'; }"), | 12 const TestEntry("main() { return true ? 42 : 'foo'; }"), |
13 const TestEntry(""" | 13 const TestEntry(""" |
14 foo() => foo(); | 14 foo() => foo(); |
15 main() { | 15 main() { |
16 print(foo() ? "hello world" : "bad bad"); | 16 print(foo() ? "hello world" : "bad bad"); |
17 }""", | 17 }""", |
18 """function() { | 18 """function() { |
19 P.print(P.identical(V.foo(), true) ? "hello world" : "bad bad"); | 19 V.foo(); |
| 20 P.print("bad bad"); |
20 return null; | 21 return null; |
21 }"""), | 22 }"""), |
22 const TestEntry(""" | 23 const TestEntry(""" |
| 24 foo() => null; |
| 25 main() { |
| 26 print(foo() ? "hello world" : "bad bad"); |
| 27 }""", |
| 28 """function() { |
| 29 V.foo(); |
| 30 P.print("bad bad"); |
| 31 return null; |
| 32 }"""), |
| 33 const TestEntry(""" |
23 get foo => foo; | 34 get foo => foo; |
24 main() { | 35 main() { |
25 print(foo ? "hello world" : "bad bad"); | 36 print(foo ? "hello world" : "bad bad"); |
26 }""", | 37 }""", |
27 """function() { | 38 """function() { |
28 P.print(P.identical(V.foo(), true) ? "hello world" : "bad bad"); | 39 V.foo(); |
| 40 P.print("bad bad"); |
29 return null; | 41 return null; |
30 }"""), | 42 }"""), |
31 const TestEntry(""" | 43 const TestEntry(""" |
32 get foo => foo; | 44 get foo => foo; |
33 main() { print(foo && foo); }""", | 45 main() { print(foo && foo); }""", |
34 """function() { | 46 """function() { |
35 P.print(P.identical(V.foo(), true) && P.identical(V.foo(), true)); | 47 V.foo(); |
| 48 P.print(false); |
36 return null; | 49 return null; |
37 }"""), | 50 }"""), |
38 const TestEntry(""" | 51 const TestEntry(""" |
39 get foo => foo; | 52 get foo => foo; |
40 main() { print(foo || foo); }""", | 53 main() { print(foo || foo); }""", |
41 """function() { | 54 """function() { |
42 P.print(P.identical(V.foo(), true) || P.identical(V.foo(), true)); | 55 V.foo(); |
| 56 V.foo(); |
| 57 P.print(false); |
43 return null; | 58 return null; |
44 }"""), | 59 }"""), |
45 | 60 |
46 // Needs interceptor calling convention | 61 // Needs interceptor calling convention |
47 //const TestEntry(""" | 62 //const TestEntry(""" |
48 //class Foo { | 63 //class Foo { |
49 // operator[]=(index, value) { | 64 // operator[]=(index, value) { |
50 // print(value); | 65 // print(value); |
51 // } | 66 // } |
52 //} | 67 //} |
(...skipping 16 matching lines...) Expand all Loading... |
69 var list = [1, 2, 3]; | 84 var list = [1, 2, 3]; |
70 J.getInterceptor$a(list).$indexSet(list, 1, 6); | 85 J.getInterceptor$a(list).$indexSet(list, 1, 6); |
71 P.print(list); | 86 P.print(list); |
72 return null; | 87 return null; |
73 }"""), | 88 }"""), |
74 ]; | 89 ]; |
75 | 90 |
76 void main() { | 91 void main() { |
77 runTests(tests); | 92 runTests(tests); |
78 } | 93 } |
OLD | NEW |