Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library malformed_test; | |
| 6 | |
| 7 // This part includes the actual tests. | |
| 8 part 'malformed2_lib.dart'; /// 00: static type warning | |
| 9 | |
| 10 bool inCheckedMode() { | |
| 11 try { | |
| 12 var i = 42; | |
| 13 String s = i; | |
| 14 } on TypeError catch (e) { | |
| 15 return true; | |
| 16 } | |
| 17 return false; | |
| 18 } | |
| 19 | |
| 20 | |
| 21 bool hasFailed = false; | |
| 22 void fail(String message) { | |
|
karlklose
2013/11/05 09:48:14
Add a new line here and after the method.
Johnni Winther
2013/11/05 10:58:41
Done.
| |
| 23 try { | |
| 24 throw message; | |
| 25 } catch (e, s) { | |
| 26 print(e); | |
| 27 print(s); | |
| 28 } | |
| 29 hasFailed = true; | |
| 30 } | |
| 31 void checkFailures() { | |
| 32 if (hasFailed) throw 'Test failed.'; | |
| 33 } | |
| 34 | |
| 35 test(bool expectTypeError, f(), [String message]) { | |
| 36 message = message != null ? ' for $message' : ''; | |
| 37 if (expectTypeError) { | |
|
karlklose
2013/11/05 09:48:14
If you test expectTypeError directly in line 40 an
Johnni Winther
2013/11/05 10:58:41
Done.
| |
| 38 try { | |
| 39 f(); | |
| 40 fail('Missing type error$message.'); | |
| 41 } on TypeError catch (e) { | |
| 42 print('Type error$message: $e'); | |
| 43 } | |
| 44 } else { | |
| 45 try { | |
| 46 f(); | |
| 47 } on TypeError catch (e) { | |
| 48 fail('Unexpected type error$message: $e'); | |
| 49 } | |
| 50 } | |
| 51 } | |
| 52 | |
| 53 void main() { | |
| 54 testValue(new List<String>()); /// 00: continued | |
| 55 testValue(null); /// 00: continued | |
| 56 checkFailures(); | |
| 57 } | |
| OLD | NEW |