OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 // Test that Object.dynamic returns the identical object. |
| 6 |
| 7 main() { |
| 8 // Primitives |
| 9 var anInt = 5; |
| 10 var aString = 'Hello'; |
| 11 var aBool = true; |
| 12 var aDouble = 3.14159; |
| 13 |
| 14 // Compounds |
| 15 var aMap = {}; |
| 16 |
| 17 // The type should not change. |
| 18 Expect.isTrue(dyn(anInt) is int, 'is int'); |
| 19 Expect.isTrue(dyn(aString) is String, 'is String'); |
| 20 Expect.isTrue(dyn(aBool) is bool, 'is bool'); |
| 21 Expect.isTrue(dyn(aMap) is Map, 'is Map'); |
| 22 |
| 23 // The object should be identical. |
| 24 Expect.isTrue(eq(anInt, anInt.dynamic), 'anInt.dynamic'); |
| 25 Expect.isTrue(eq(aString, aString.dynamic), 'aString.dynamic'); |
| 26 Expect.isTrue(eq(aBool, aBool.dynamic), 'aBool.dynamic'); |
| 27 Expect.isTrue(eq(aDouble, aDouble.dynamic), 'aDouble.dynamic'); |
| 28 Expect.isTrue(eq(aMap, aMap.dynamic), 'aMap.dynamic'); |
| 29 } |
| 30 |
| 31 dyn(x) => x.dynamic; |
| 32 |
| 33 eq(a, b) => a === b; |
OLD | NEW |