OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 'dart:async'; | 5 import 'dart:async'; |
6 import 'package:expect/expect.dart'; | 6 import 'package:expect/expect.dart'; |
7 import 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
8 import 'compiler_helper.dart'; | 8 import 'compiler_helper.dart'; |
9 | 9 |
10 const String TEST_ONE = r""" | 10 const String TEST_ONE = r""" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 main() { | 102 main() { |
103 var a = new A(); | 103 var a = new A(); |
104 var b = new A.bar(); | 104 var b = new A.bar(); |
105 for (int i = 0; i < a.field; i++) { a.field = 42; b.field = 42; } | 105 for (int i = 0; i < a.field; i++) { a.field = 42; b.field = 42; } |
106 } | 106 } |
107 """; | 107 """; |
108 | 108 |
109 main() { | 109 main() { |
110 asyncTest(() => Future.wait([ | 110 asyncTest(() => Future.wait([ |
111 compile(TEST_ONE, entry: 'foo', check: (String generated) { | 111 compile(TEST_ONE, entry: 'foo', check: (String generated) { |
112 RegExp regexp = new RegExp(r"1 \+ [a-z]+"); | 112 RegExp regexp = new RegExp(r"1 \+ [a-z]+"); |
113 checkNumberOfMatches(regexp.allMatches(generated).iterator, 1); | 113 checkNumberOfMatches(regexp.allMatches(generated).iterator, 1); |
114 }), | 114 }), |
115 | 115 compile(TEST_TWO, entry: 'foo', check: (String generated) { |
116 compile(TEST_TWO, entry: 'foo', check: (String generated) { | 116 checkNumberOfMatches( |
117 checkNumberOfMatches( | 117 new RegExp("length").allMatches(generated).iterator, 1); |
118 new RegExp("length").allMatches(generated).iterator, 1); | 118 }), |
119 }), | 119 compile(TEST_THREE, entry: 'foo', check: (String generated) { |
120 | 120 checkNumberOfMatches( |
121 compile(TEST_THREE, entry: 'foo', check: (String generated) { | 121 new RegExp("number").allMatches(generated).iterator, 1); |
122 checkNumberOfMatches( | 122 }), |
123 new RegExp("number").allMatches(generated).iterator, 1); | 123 compile(TEST_FOUR, entry: 'foo', check: (String generated) { |
124 }), | 124 checkNumberOfMatches( |
125 | 125 new RegExp("shr").allMatches(generated).iterator, 1); |
126 compile(TEST_FOUR, entry: 'foo', check: (String generated) { | 126 }), |
127 checkNumberOfMatches(new RegExp("shr").allMatches(generated).iterator, 1); | 127 compileAll(TEST_FIVE).then((generated) { |
128 }), | 128 checkNumberOfMatches( |
129 | 129 new RegExp("get\\\$foo").allMatches(generated).iterator, 1); |
130 compileAll(TEST_FIVE).then((generated) { | 130 }), |
131 checkNumberOfMatches( | 131 compileAll(TEST_SIX).then((generated) { |
132 new RegExp("get\\\$foo").allMatches(generated).iterator, 1); | 132 Expect.isTrue(generated.contains('for (t1 = a.field === 54; t1;)')); |
133 }), | 133 }), |
134 | 134 compileAll(TEST_SEVEN).then((generated) { |
135 compileAll(TEST_SIX).then((generated) { | 135 Expect.isTrue(generated.contains('for (t1 = a.field === 54; t1;)')); |
136 Expect.isTrue(generated.contains('for (t1 = a.field === 54; t1;)')); | 136 }), |
137 }), | 137 compileAll(TEST_EIGHT).then((generated) { |
138 | 138 Expect.isTrue(generated.contains('for (; i < t1; ++i)')); |
139 compileAll(TEST_SEVEN).then((generated) { | 139 }), |
140 Expect.isTrue(generated.contains('for (t1 = a.field === 54; t1;)')); | 140 ])); |
141 }), | |
142 | |
143 compileAll(TEST_EIGHT).then((generated) { | |
144 Expect.isTrue(generated.contains('for (; i < t1; ++i)')); | |
145 }), | |
146 ])); | |
147 } | 141 } |
OLD | NEW |