| 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 // VMOptions=--enable_type_checks | 4 // VMOptions=--enable_type_checks |
| 5 // | 5 // |
| 6 // Dart test program testing type checks in list literals. | 6 // Dart test program testing type checks in list literals. |
| 7 | 7 |
| 8 class ListLiteral4Test<T> { | 8 class ListLiteral4Test<T> { |
| 9 test() { | 9 test() { |
| 10 int result = 0; | 10 int result = 0; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 m["0"] = 1; // "0" is not an int. | 34 m["0"] = 1; // "0" is not an int. |
| 35 } catch (TypeError error) { | 35 } catch (TypeError error) { |
| 36 result += 10000; | 36 result += 10000; |
| 37 } | 37 } |
| 38 try { | 38 try { |
| 39 var m = const <int>[0, 1]; | 39 var m = const <int>[0, 1]; |
| 40 m["0"] = 1; // "0" is not an int. | 40 m["0"] = 1; // "0" is not an int. |
| 41 } catch (TypeError error) { | 41 } catch (TypeError error) { |
| 42 result += 100000; | 42 result += 100000; |
| 43 } | 43 } |
| 44 try { |
| 45 var m = <T>[0, 1]; // OK. Tested above. |
| 46 List<String> ls = m; // m is a List<int>, not a List<String>. |
| 47 } catch (TypeError error) { |
| 48 result += 1000000; |
| 49 } |
| 50 |
| 44 return result; | 51 return result; |
| 45 } | 52 } |
| 46 } | 53 } |
| 47 | 54 |
| 48 main() { | 55 main() { |
| 49 var t = new ListLiteral4Test<int>(); | 56 var t = new ListLiteral4Test<int>(); |
| 50 Expect.equals(110111, t.test()); | 57 Expect.equals(1110111, t.test()); |
| 51 } | 58 } |
| 52 | 59 |
| 53 | 60 |
| OLD | NEW |