| 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 }), | 449 }), |
| 450 statics: () => ({ | 450 statics: () => ({ |
| 451 s: [core.String, [core.String]] | 451 s: [core.String, [core.String]] |
| 452 }), | 452 }), |
| 453 names: ['s'] | 453 names: ['s'] |
| 454 }) | 454 }) |
| 455 let o = new Tester(); | 455 let o = new Tester(); |
| 456 | 456 |
| 457 // Method send | 457 // Method send |
| 458 assert.equal(dart.dsend(o, 'm', 3, 4), 3); | 458 assert.equal(dart.dsend(o, 'm', 3, 4), 3); |
| 459 assert.equal(dart.dsend(o, 'm', null, 4), null); |
| 459 assert.throws(() => dart.dsend(o, 'm', 3)); | 460 assert.throws(() => dart.dsend(o, 'm', 3)); |
| 460 assert.throws(() => dart.dsend(o, 'm', "hello", "world")); | 461 assert.throws(() => dart.dsend(o, 'm', "hello", "world")); |
| 461 assert.throws(() => dart.dsend(o, 'q', 3)); | 462 assert.throws(() => dart.dsend(o, 'q', 3)); |
| 462 | 463 |
| 463 // Method send through a field | 464 // Method send through a field |
| 464 assert.equal(dart.dsend(o, 'f', 3), 3); | 465 assert.equal(dart.dsend(o, 'f', 3), 3); |
| 466 assert.equal(dart.dsend(o, 'f', null), null); |
| 465 assert.throws(() => dart.dsend(o, 'f', "hello")); | 467 assert.throws(() => dart.dsend(o, 'f', "hello")); |
| 466 assert.throws(() => dart.dsend(o, 'f', 3, 4)); | 468 assert.throws(() => dart.dsend(o, 'f', 3, 4)); |
| 467 | 469 |
| 468 // Static method call | 470 // Static method call |
| 469 assert.equal(dart.dcall(Tester.s, "hello"), "hello"); | 471 assert.equal(dart.dcall(Tester.s, "hello"), "hello"); |
| 472 assert.equal(dart.dcall(Tester.s, null), null); |
| 470 assert.throws(() => dart.dcall(Tester.s, "hello", "world")); | 473 assert.throws(() => dart.dcall(Tester.s, "hello", "world")); |
| 471 assert.throws(() => dart.dcall(Tester.s, 0, 1)); | 474 assert.throws(() => dart.dcall(Tester.s, 0, 1)); |
| 472 | 475 |
| 473 // Calling an object with a call method | 476 // Calling an object with a call method |
| 474 assert.equal(dart.dcall(o, 3), 3); | 477 assert.equal(dart.dcall(o, 3), 3); |
| 478 assert.equal(dart.dcall(o, null), null); |
| 475 assert.throws(() => dart.dcall(o, "hello")); | 479 assert.throws(() => dart.dcall(o, "hello")); |
| 476 assert.throws(() => dart.dcall(o, 3, 4)); | 480 assert.throws(() => dart.dcall(o, 3, 4)); |
| 477 | 481 |
| 478 // Calling through a field containing an object with a call method | 482 // Calling through a field containing an object with a call method |
| 479 assert.equal(dart.dsend(o, 'me', 3), 3); | 483 assert.equal(dart.dsend(o, 'me', 3), 3); |
| 484 assert.equal(dart.dsend(o, 'me', null), null); |
| 480 assert.throws(() => dart.dsend(o, 'me', "hello")); | 485 assert.throws(() => dart.dsend(o, 'me', "hello")); |
| 481 assert.throws(() => dart.dsend(o, 'me', 3, 4)); | 486 assert.throws(() => dart.dsend(o, 'me', 3, 4)); |
| 482 }); | 487 }); |
| 483 | 488 |
| 484 test('Types on top level functions', () => { | 489 test('Types on top level functions', () => { |
| 485 // Test some generated code | 490 // Test some generated code |
| 486 // Test the lazy path | 491 // Test the lazy path |
| 487 checkType(core.identityHashCode, | 492 checkType(core.identityHashCode, |
| 488 dart.functionType(core.int, [core.Object])); | 493 dart.functionType(core.int, [core.Object])); |
| 489 // Test the normal path | 494 // Test the normal path |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 | 679 |
| 675 suite('primitives', function() { | 680 suite('primitives', function() { |
| 676 'use strict'; | 681 'use strict'; |
| 677 | 682 |
| 678 test('fixed length list', () => { | 683 test('fixed length list', () => { |
| 679 let list = new core.List(10); | 684 let list = new core.List(10); |
| 680 list[0] = 42; | 685 list[0] = 42; |
| 681 assert.throws(() => list.add(42)); | 686 assert.throws(() => list.add(42)); |
| 682 }); | 687 }); |
| 683 }); | 688 }); |
| OLD | NEW |