| 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 | 4 |
| 5 var assert = chai.assert; | 5 var assert = chai.assert; |
| 6 | 6 |
| 7 suite('generic', () => { | 7 suite('generic', () => { |
| 8 "use strict"; | 8 "use strict"; |
| 9 | 9 |
| 10 let generic = dart.generic; | 10 let generic = dart.generic; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 let expect = assert.equal; | 88 let expect = assert.equal; |
| 89 let isGroundType = dart.isGroundType; | 89 let isGroundType = dart.isGroundType; |
| 90 let generic = dart.generic; | 90 let generic = dart.generic; |
| 91 let intIsNonNullable = false; | 91 let intIsNonNullable = false; |
| 92 let cast = dart.as; | 92 let cast = dart.as; |
| 93 let instanceOf = dart.is; | 93 let instanceOf = dart.is; |
| 94 let runtimeType = dart.realRuntimeType; | 94 let runtimeType = dart.realRuntimeType; |
| 95 let functionType = dart.functionType; | 95 let functionType = dart.functionType; |
| 96 let typedef = dart.typedef; | 96 let typedef = dart.typedef; |
| 97 let isSubtype = dart.isSubtype; |
| 97 | 98 |
| 98 let Object = core.Object; | 99 let Object = core.Object; |
| 99 let String = core.String; | 100 let String = core.String; |
| 100 let dynamic = dart.dynamic; | 101 let dynamic = dart.dynamic; |
| 101 let List = core.List; | 102 let List = core.List; |
| 102 let Map = core.Map; | 103 let Map = core.Map; |
| 103 let Map$ = core.Map$; | 104 let Map$ = core.Map$; |
| 104 let int = core.int; | 105 let int = core.int; |
| 105 let num = core.num; | 106 let num = core.num; |
| 106 let bool = core.bool; | 107 let bool = core.bool; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 checkType(m2, Map$(String, String), false); | 271 checkType(m2, Map$(String, String), false); |
| 271 | 272 |
| 272 // null is! Map | 273 // null is! Map |
| 273 checkType(null, Map, false); | 274 checkType(null, Map, false); |
| 274 | 275 |
| 275 // Raw generic types | 276 // Raw generic types |
| 276 checkType(m5, Map); | 277 checkType(m5, Map); |
| 277 checkType(m4, Map); | 278 checkType(m4, Map); |
| 278 }); | 279 }); |
| 279 | 280 |
| 281 test('constructors', () => { |
| 282 class C extends core.Object { |
| 283 C(x) {}; |
| 284 named(x, y) {}; |
| 285 } |
| 286 dart.defineNamedConstructor(C, 'named'); |
| 287 dart.setSignature(C, { |
| 288 constructors: () => ({ |
| 289 C: [C, [core.int]], |
| 290 named: [C, [core.int, core.int]] |
| 291 }) |
| 292 }); |
| 293 let getType = dart.classGetConstructorType; |
| 294 isSubtype(getType(C), dart.functionType(C, [core.int])); |
| 295 isSubtype(getType(C), dart.functionType(C, [core.String]), false); |
| 296 isSubtype(getType(C, 'C'), dart.functionType(C, [core.int])); |
| 297 isSubtype(getType(C, 'C'), dart.functionType(C, [core.String]), false); |
| 298 isSubtype(getType(C, 'named'), dart.functionType(C, [core.int, core.int])); |
| 299 isSubtype(getType(C, 'named'), |
| 300 dart.functionType(C, [core.int, core.String]), false); |
| 301 }); |
| 302 |
| 280 test('generic and inheritance', () => { | 303 test('generic and inheritance', () => { |
| 281 let aaraw = new AA(); | 304 let aaraw = new AA(); |
| 282 let aarawtype = runtimeType(aaraw); | 305 let aarawtype = runtimeType(aaraw); |
| 283 let aadynamic = new (AA$(dynamic, dynamic))(); | 306 let aadynamic = new (AA$(dynamic, dynamic))(); |
| 284 let aadynamictype = runtimeType(aadynamic); | 307 let aadynamictype = runtimeType(aadynamic); |
| 285 let aa = new (AA$(String, List))(); | 308 let aa = new (AA$(String, List))(); |
| 286 let aatype = runtimeType(aa); | 309 let aatype = runtimeType(aa); |
| 287 let bb = new (BB$(String, List))(); | 310 let bb = new (BB$(String, List))(); |
| 288 let bbtype = runtimeType(bb); | 311 let bbtype = runtimeType(bb); |
| 289 let cc = new CC(); | 312 let cc = new CC(); |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 | 697 |
| 675 suite('primitives', function() { | 698 suite('primitives', function() { |
| 676 'use strict'; | 699 'use strict'; |
| 677 | 700 |
| 678 test('fixed length list', () => { | 701 test('fixed length list', () => { |
| 679 let list = new core.List(10); | 702 let list = new core.List(10); |
| 680 list[0] = 42; | 703 list[0] = 42; |
| 681 assert.throws(() => list.add(42)); | 704 assert.throws(() => list.add(42)); |
| 682 }); | 705 }); |
| 683 }); | 706 }); |
| OLD | NEW |