Chromium Code Reviews| Index: tests/language/malformed2_test.dart |
| diff --git a/tests/language/malformed2_test.dart b/tests/language/malformed2_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b42a4e75faa9bf194209575ac04b6bf853a7d80f |
| --- /dev/null |
| +++ b/tests/language/malformed2_test.dart |
| @@ -0,0 +1,57 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library malformed_test; |
| + |
| +// This part includes the actual tests. |
| +part 'malformed2_lib.dart'; /// 00: static type warning |
| + |
| +bool inCheckedMode() { |
| + try { |
| + var i = 42; |
| + String s = i; |
| + } on TypeError catch (e) { |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| + |
| +bool hasFailed = false; |
| +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.
|
| + try { |
| + throw message; |
| + } catch (e, s) { |
| + print(e); |
| + print(s); |
| + } |
| + hasFailed = true; |
| +} |
| +void checkFailures() { |
| + if (hasFailed) throw 'Test failed.'; |
| +} |
| + |
| +test(bool expectTypeError, f(), [String message]) { |
| + message = message != null ? ' for $message' : ''; |
| + 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.
|
| + try { |
| + f(); |
| + fail('Missing type error$message.'); |
| + } on TypeError catch (e) { |
| + print('Type error$message: $e'); |
| + } |
| + } else { |
| + try { |
| + f(); |
| + } on TypeError catch (e) { |
| + fail('Unexpected type error$message: $e'); |
| + } |
| + } |
| +} |
| + |
| +void main() { |
| + testValue(new List<String>()); /// 00: continued |
| + testValue(null); /// 00: continued |
| + checkFailures(); |
| +} |