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""" |
11 void foo(bar) { | 11 void foo(bar) { |
12 var toBeRemoved = 1; | 12 var toBeRemoved = 1; |
13 if (bar) { | 13 if (bar) { |
14 } else { | 14 } else { |
15 } | 15 } |
16 print(toBeRemoved); | 16 print(toBeRemoved); |
17 } | 17 } |
18 """; | 18 """; |
19 | 19 |
20 | |
21 const String TEST_TWO = r""" | 20 const String TEST_TWO = r""" |
22 void foo() { | 21 void foo() { |
23 var temp = 0; | 22 var temp = 0; |
24 var toBeRemoved = temp; | 23 var toBeRemoved = temp; |
25 for (var i = 0; i == 0; i = i + 1) { | 24 for (var i = 0; i == 0; i = i + 1) { |
26 toBeRemoved = temp; | 25 toBeRemoved = temp; |
27 } | 26 } |
28 print(toBeRemoved); | 27 print(toBeRemoved); |
29 } | 28 } |
30 """; | 29 """; |
31 | 30 |
32 main() { | 31 main() { |
33 asyncTest(() => Future.wait([ | 32 asyncTest(() => Future.wait([ |
34 compile(TEST_ONE, entry: 'foo', check: (String generated) { | 33 compile(TEST_ONE, entry: 'foo', check: (String generated) { |
35 RegExp regexp = new RegExp("toBeRemoved"); | 34 RegExp regexp = new RegExp("toBeRemoved"); |
36 Expect.isTrue(!regexp.hasMatch(generated)); | 35 Expect.isTrue(!regexp.hasMatch(generated)); |
37 }), | 36 }), |
38 | 37 compile(TEST_TWO, entry: 'foo', check: (String generated) { |
39 compile(TEST_TWO, entry: 'foo', check: (String generated) { | 38 RegExp regexp = new RegExp("toBeRemoved"); |
40 RegExp regexp = new RegExp("toBeRemoved"); | 39 Expect.isTrue(!regexp.hasMatch(generated)); |
41 Expect.isTrue(!regexp.hasMatch(generated)); | 40 regexp = new RegExp("temp"); |
42 regexp = new RegExp("temp"); | 41 Expect.isTrue(!regexp.hasMatch(generated)); |
43 Expect.isTrue(!regexp.hasMatch(generated)); | 42 }), |
44 }), | 43 ])); |
45 ])); | |
46 } | 44 } |
OLD | NEW |