| 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 var core = dart_library.import('dart/core'); | 6 var core = dart_library.import('dart/core'); |
| 7 var collection = dart_library.import('dart/collection'); | 7 var collection = dart_library.import('dart/collection'); |
| 8 var dart = dart_library.import('dart_runtime/dart'); | 8 var dart = dart_library.import('dart_runtime/dart'); |
| 9 var dartx = dart.dartx; | 9 var dartx = dart.dartx; |
| 10 | 10 |
| 11 // TODO(leafp): These are here to test some things not | 11 // TODO(leafp): These are here to test some things not |
| 12 // currently exposed through the main dart entry point. | 12 // currently exposed through the main dart entry point. |
| 13 // If we decide to expose them, this can go away. | 13 // If we decide to expose them, this can go away. |
| 14 var classes = dart_library.import('dart_runtime/_classes'); | 14 var classes = dart_library.import('dart_runtime/_classes'); |
| 15 var types = dart_library.import('dart_runtime/_types'); | 15 var types = dart_library.import('dart_runtime/_types'); |
| 16 | 16 |
| 17 suite('generic', () => { | 17 suite('generic', () => { |
| 18 "use strict"; | 18 "use strict"; |
| 19 | 19 |
| 20 let generic = dart.generic; | 20 let generic = dart.generic; |
| 21 | 21 |
| 22 test('zero arguments is not allowed', () => { | 22 test('zero arguments is not allowed', () => { |
| 23 assert.throws(() => { generic(function(){}); }); | 23 assert.throws(() => { generic(function(){}); }); |
| 24 }); | 24 }); |
| 25 | 25 |
| 26 test('can throw number', () => { |
| 27 try { |
| 28 dart.throw(42); |
| 29 } catch (e) { |
| 30 assert.equal(e, 42); |
| 31 } |
| 32 }); |
| 33 |
| 26 test('argument count cannot change', () => { | 34 test('argument count cannot change', () => { |
| 27 let SomeType = generic(function(x) { return {x: x}; }); | 35 let SomeType = generic(function(x) { return {x: x}; }); |
| 28 assert.throws(() => { SomeType(1,2) }); | 36 assert.throws(() => { SomeType(1,2) }); |
| 29 let obj = {}; | 37 let obj = {}; |
| 30 assert.equal(SomeType(obj).x, obj); | 38 assert.equal(SomeType(obj).x, obj); |
| 31 assert.equal(SomeType(obj).x, obj); | 39 assert.equal(SomeType(obj).x, obj); |
| 32 assert.equal(SomeType().x, dart.dynamic); | 40 assert.equal(SomeType().x, dart.dynamic); |
| 33 }); | 41 }); |
| 34 | 42 |
| 35 test('undefined/null are not allowed', () => { | 43 test('undefined/null are not allowed', () => { |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 | 737 |
| 730 suite('primitives', function() { | 738 suite('primitives', function() { |
| 731 'use strict'; | 739 'use strict'; |
| 732 | 740 |
| 733 test('fixed length list', () => { | 741 test('fixed length list', () => { |
| 734 let list = new core.List(10); | 742 let list = new core.List(10); |
| 735 list[0] = 42; | 743 list[0] = 42; |
| 736 assert.throws(() => list.add(42)); | 744 assert.throws(() => list.add(42)); |
| 737 }); | 745 }); |
| 738 }); | 746 }); |
| OLD | NEW |