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