| 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 // Unresolved symbols should be reported as an error. | 5 // Unresolved imported symbols are handled differently in production mode and |
| 6 // check modes. In this test, the function myFunc is malformed, because |
| 7 // lib12.Library13 is not resolved. |
| 8 // In checked mode, the assignment type check throws a run time type error. |
| 9 // In production, no assignment type checks are performed. |
| 6 | 10 |
| 7 #library("Prefix16NegativeTest.dart"); | 11 #library("Prefix16NegativeTest.dart"); |
| 8 #import("library12.dart", prefix:"lib12"); | 12 #import("library12.dart", prefix:"lib12"); |
| 9 | 13 |
| 10 typedef lib12.Library13 myFunc(lib12.Library13 param); | 14 typedef lib12.Library13 myFunc(lib12.Library13 param); |
| 11 | 15 |
| 16 isCheckedMode() { |
| 17 try { |
| 18 var i = 1; |
| 19 String s = i; |
| 20 return false; |
| 21 } catch(var e) { |
| 22 return true; |
| 23 } |
| 24 } |
| 25 |
| 12 main() { | 26 main() { |
| 13 myFunc i = 0; | 27 { |
| 28 bool got_type_error = false; |
| 29 try { |
| 30 myFunc i = 0; |
| 31 } catch (TypeError error) { |
| 32 got_type_error = true; |
| 33 } |
| 34 // Type error in checked mode only. |
| 35 Expect.isTrue(got_type_error == isCheckedMode()); |
| 36 } |
| 37 { |
| 38 bool got_type_error = false; |
| 39 try { |
| 40 // In production mode, malformed myFunc is mapped to (Dynamic) => Dynamic. |
| 41 Expect.isTrue(((int x) => x) is myFunc); |
| 42 } catch (TypeError error) { |
| 43 got_type_error = true; |
| 44 } |
| 45 // Type error in checked mode only. |
| 46 Expect.isTrue(got_type_error == isCheckedMode()); |
| 47 } |
| 14 } | 48 } |
| OLD | NEW |