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 // Regression test for http://dartbug.com/10231. | 5 // Regression test for http://dartbug.com/10231. |
6 | 6 |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 import 'codegen_helper.dart'; | 8 import 'codegen_helper.dart'; |
9 | 9 |
10 void main() { | 10 void main() { |
11 var code = generate(SOURCE)['test']; | 11 generate(SOURCE).then((result) { |
12 Expect.isNotNull(code); | 12 var code = result['test']; |
13 Expect.equals(0, new RegExp('add').allMatches(code).length); | 13 Expect.isNotNull(code); |
14 Expect.equals(3, new RegExp('\\+').allMatches(code).length); | 14 Expect.equals(0, new RegExp('add').allMatches(code).length); |
| 15 Expect.equals(3, new RegExp('\\+').allMatches(code).length); |
| 16 }); |
15 } | 17 } |
16 | 18 |
17 const String SOURCE = """ | 19 const String SOURCE = """ |
18 test(a, b, c, d) { | 20 test(a, b, c, d) { |
19 if (a is !num) throw 'a not num'; | 21 if (a is !num) throw 'a not num'; |
20 if (b is !num) throw 'b not num'; | 22 if (b is !num) throw 'b not num'; |
21 if (c is !num) throw 'c not num'; | 23 if (c is !num) throw 'c not num'; |
22 if (d is !num) throw 'd not num'; | 24 if (d is !num) throw 'd not num'; |
23 return a + b + c + d; | 25 return a + b + c + d; |
24 } | 26 } |
25 | 27 |
26 main() { | 28 main() { |
27 test(1, 2, 3, 4); | 29 test(1, 2, 3, 4); |
28 test('x', 'y', 'z', 'w'); | 30 test('x', 'y', 'z', 'w'); |
29 test([], {}, [], {}); | 31 test([], {}, [], {}); |
30 } | 32 } |
31 """; | 33 """; |
OLD | NEW |