OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import "package:async_helper/async_helper.dart"; | 6 import "package:async_helper/async_helper.dart"; |
7 import 'compiler_helper.dart'; | 7 import 'compiler_helper.dart'; |
8 | 8 |
9 const String TEST1 = r""" | 9 const String TEST1 = r""" |
10 main() { | 10 main() { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 String generateTest(String call) { | 59 String generateTest(String call) { |
60 return """ | 60 return """ |
61 main() { | 61 main() { |
62 List differentType = [true, false]; | 62 List differentType = [true, false]; |
63 List a = [42]; | 63 List a = [42]; |
64 return a.$call + 42; | 64 return a.$call + 42; |
65 } | 65 } |
66 """; | 66 """; |
67 } | 67 } |
68 | 68 |
69 | |
70 main() { | 69 main() { |
71 asyncTest(() => compileAll(TEST1).then((generated) { | 70 asyncTest(() => compileAll(TEST1).then((generated) { |
72 Expect.isTrue(generated.contains('if (typeof t1')); | 71 Expect.isTrue(generated.contains('if (typeof t1')); |
73 })); | 72 })); |
74 | 73 |
75 asyncTest(() => compileAll(TEST2).then((generated) { | 74 asyncTest(() => compileAll(TEST2).then((generated) { |
76 Expect.isTrue(generated.contains('if (typeof t1')); | 75 Expect.isTrue(generated.contains('if (typeof t1')); |
77 })); | 76 })); |
78 | 77 |
79 asyncTest(() => compileAll(TEST3).then((generated) { | 78 asyncTest(() => compileAll(TEST3).then((generated) { |
80 Expect.isTrue(generated.contains('if (typeof t1')); | 79 Expect.isTrue(generated.contains('if (typeof t1')); |
81 })); | 80 })); |
82 | 81 |
83 asyncTest(() => compileAll(TEST4).then((generated) { | 82 asyncTest(() => compileAll(TEST4).then((generated) { |
84 Expect.isTrue(generated.contains('if (typeof t1')); | 83 Expect.isTrue(generated.contains('if (typeof t1')); |
85 })); | 84 })); |
86 | 85 |
87 asyncTest(() => compileAll(TEST5).then((generated) { | 86 asyncTest(() => compileAll(TEST5).then((generated) { |
88 Expect.isFalse(generated.contains('iae')); | 87 Expect.isFalse(generated.contains('iae')); |
89 })); | 88 })); |
90 | 89 |
91 asyncTest(() => compileAll(TEST6).then((generated) { | 90 asyncTest(() => compileAll(TEST6).then((generated) { |
92 Expect.isFalse(generated.contains('iae')); | 91 Expect.isFalse(generated.contains('iae')); |
93 })); | 92 })); |
94 | 93 |
95 var memberInvocations = const <String>[ | 94 var memberInvocations = const <String>[ |
96 'first', | 95 'first', |
97 'last', | 96 'last', |
98 'single', | 97 'single', |
99 'singleWhere((x) => true)', | 98 'singleWhere((x) => true)', |
100 'elementAt(0)', | 99 'elementAt(0)', |
101 'removeAt(0)', | 100 'removeAt(0)', |
102 'removeLast()', | 101 'removeLast()', |
103 ]; | 102 ]; |
104 memberInvocations.map((member) => generateTest('$member')) | 103 memberInvocations |
| 104 .map((member) => generateTest('$member')) |
105 .forEach((String test) { | 105 .forEach((String test) { |
106 asyncTest(() => compileAll(test, expectedErrors: 0, expectedWarnings: 0) | 106 asyncTest(() => compileAll(test, expectedErrors: 0, expectedWarnings: 0) |
107 .then((generated) { | 107 .then((generated) { |
108 Expect.isTrue(generated.contains('+ 42')); | 108 Expect.isTrue(generated.contains('+ 42')); |
109 Expect.isFalse(generated.contains('if (typeof t1')); | 109 Expect.isFalse(generated.contains('if (typeof t1')); |
110 Expect.isFalse(generated.contains('if (t1 == null)')); | 110 Expect.isFalse(generated.contains('if (t1 == null)')); |
111 })); | 111 })); |
112 }); | 112 }); |
113 | |
114 } | 113 } |
OLD | NEW |