| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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=--compile_all --error_on_bad_type --error_on_bad_override | 4 // VMOptions=--compile_all --error_on_bad_type --error_on_bad_override |
| 5 | 5 |
| 6 import 'package:observatory/object_graph.dart'; | 6 import 'package:observatory/object_graph.dart'; |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 |
| 9 dynamic confuse() { |
| 10 if (true) { |
| 11 return "5"; |
| 12 } |
| 13 return 5; |
| 14 } |
| 8 | 15 |
| 9 main() { | 16 main() { |
| 10 var map = new AddressMapper(42); | 17 var map = new AddressMapper(42); |
| 11 | 18 |
| 12 Expect.equals(null, map.get(1, 2, 3)); | 19 expect(map.get(1, 2, 3), isNull); |
| 13 Expect.equals(4, map.put(1, 2, 3, 4)); | 20 expect(map.put(1, 2, 3, 4), equals(4)); |
| 14 Expect.equals(4, map.get(1, 2, 3)); | 21 expect(map.get(1, 2, 3), equals(4)); |
| 15 | 22 |
| 16 Expect.equals(null, map.get(2, 3, 1)); | 23 expect(map.get(2, 3, 1), isNull); |
| 17 Expect.equals(null, map.get(3, 1, 2)); | 24 expect(map.get(3, 1, 2), isNull); |
| 18 | 25 |
| 19 Expect.throws(() => map.put(1, 2, 3, 44), | 26 bool exceptionThrown = false; |
| 20 (e) => true, | 27 try { |
| 21 "Overwrite key"); | 28 expect(exceptionThrown, isFalse); |
| 29 map.put(1, 2, 3, 44); |
| 30 expect(true, isFalse); |
| 31 } catch (e) { |
| 32 exceptionThrown = true; |
| 33 } |
| 34 expect(exceptionThrown, isTrue); |
| 22 | 35 |
| 23 Expect.throws(() => map.put(5, 6, 7, 0), | 36 exceptionThrown = false; |
| 24 (e) => true, | 37 try { |
| 25 "Invalid value"); | 38 expect(exceptionThrown, isFalse); |
| 39 map.put(5, 6, 7, 0); |
| 40 expect(true, isFalse); |
| 41 } catch (e) { |
| 42 exceptionThrown = true; |
| 43 } |
| 44 expect(exceptionThrown, isTrue); |
| 26 | 45 |
| 27 Expect.throws(() => map.put("5", 6, 7, 0), | 46 exceptionThrown = false; |
| 28 (e) => true, | 47 try { |
| 29 "Invalid key"); | 48 expect(exceptionThrown, isFalse); |
| 49 map.put(confuse(), 6, 7, 0); |
| 50 expect(true, isFalse); |
| 51 } catch (e) { |
| 52 exceptionThrown = true; |
| 53 } |
| 54 expect(exceptionThrown, isTrue); |
| 30 } | 55 } |
| OLD | NEW |