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'); | 8 var dart = dart_library.import('dart/_runtime'); |
9 var dartx = dart.dartx; | 9 var dartx = dart.dartx; |
10 | 10 |
11 suite('generic', () => { | 11 suite('generic', () => { |
12 "use strict"; | 12 "use strict"; |
13 | 13 |
14 let generic = dart.generic; | 14 let generic = dart.generic; |
15 | 15 |
16 test('zero arguments is not allowed', () => { | 16 test('zero arguments is not allowed', () => { |
17 assert.throws(() => { generic(function(){}); }); | 17 assert.throws(() => { generic(function(){}); }); |
18 }); | 18 }); |
19 | 19 |
20 test('dcall noSuchMethod has correct error target', () => { | 20 test('dcall noSuchMethod has correct error target', () => { |
21 assert.throws(() => dart.dcall(42), | 21 assert.throws(() => dart.dcall(42), |
22 new RegExp('NoSuchMethodError.*\nReceiver: 42', 'm'), | 22 new RegExp('NoSuchMethodError.*\nReceiver: 42', 'm'), |
23 'Calls with non-function receiver should throw a NoSuchMethodError' + | 23 'Calls with non-function receiver should throw a NoSuchMethodError' + |
24 ' with correct target'); | 24 ' with correct target'); |
25 | 25 |
26 // TODO(jmesserly): we should show the name "print" in there somewhere. | 26 // TODO(jmesserly): we should show the name "print" in there somewhere. |
27 assert.throws(() => dart.dcall(core.print, 1, 2, 3), | 27 assert.throws(() => dart.dcall(core.print, 1, 2, 3), |
28 new RegExp('NoSuchMethodError.*\n' + | 28 new RegExp('NoSuchMethodError.*\n' + |
29 "Receiver: Instance of '\\(Object\\) -> void'", 'm'), | 29 "Receiver: Instance of '\\(Object\\) -> void'", 'm'), |
30 'Calls with incorrect argument types should throw a NoSuchMethodError' + | 30 'Calls with incorrect argument types should throw a NoSuchMethodError' + |
31 ' with correct target'); | 31 ' with correct target'); |
32 }); | 32 }); |
33 | 33 |
34 test('can throw number', () => { | 34 test('can throw number', () => { |
35 try { | 35 try { |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 | 784 |
785 suite('primitives', function() { | 785 suite('primitives', function() { |
786 'use strict'; | 786 'use strict'; |
787 | 787 |
788 test('fixed length list', () => { | 788 test('fixed length list', () => { |
789 let list = new core.List(10); | 789 let list = new core.List(10); |
790 list[0] = 42; | 790 list[0] = 42; |
791 assert.throws(() => list.add(42)); | 791 assert.throws(() => list.add(42)); |
792 }); | 792 }); |
793 }); | 793 }); |
OLD | NEW |