Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: pkg/dev_compiler/test/browser/runtime_tests.js

Issue 2301973002: More DDC mirrors support (Closed)
Patch Set: Format fixes per comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 define(['dart_sdk'], function(dart_sdk) { 5 define(['dart_sdk'], function(dart_sdk) {
6 const assert = chai.assert; 6 const assert = chai.assert;
7 const core = dart_sdk.core; 7 const core = dart_sdk.core;
8 const collection = dart_sdk.collection; 8 const collection = dart_sdk.collection;
9 const dart = dart_sdk.dart; 9 const dart = dart_sdk.dart;
10 const dartx = dart.dartx; 10 const dartx = dart.dartx;
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // dart.StrongModeError); 339 // dart.StrongModeError);
340 // assert.throws(() => dart.as(m6, Map$(String, String)), 340 // assert.throws(() => dart.as(m6, Map$(String, String)),
341 // dart.StrongModeError); 341 // dart.StrongModeError);
342 assert.equal(dart.as(m1, Map$(String, String)), m1); 342 assert.equal(dart.as(m1, Map$(String, String)), m1);
343 // assert.throws(() => dart.as(m2, Map$(String, String)), 343 // assert.throws(() => dart.as(m2, Map$(String, String)),
344 // dart.StrongModeError); 344 // dart.StrongModeError);
345 }); 345 });
346 346
347 test('constructors', () => { 347 test('constructors', () => {
348 class C extends core.Object { 348 class C extends core.Object {
349 C(x) {}; 349 new(x) {};
350 named(x, y) {}; 350 named(x, y) {};
351 } 351 }
352 dart.defineNamedConstructor(C, 'named'); 352 dart.defineNamedConstructor(C, 'named');
353 dart.setSignature(C, { 353 dart.setSignature(C, {
354 constructors: () => ({ 354 constructors: () => ({
355 C: dart.definiteFunctionType(C, [core.int]), 355 new: dart.definiteFunctionType(C, [core.int]),
356 named: dart.definiteFunctionType(C, [core.int, core.int]) 356 named: dart.definiteFunctionType(C, [core.int, core.int])
357 }) 357 })
358 }); 358 });
359 let getType = dart.classGetConstructorType; 359 let getType = dart.classGetConstructorType;
360 isSubtype(getType(C), dart.functionType(C, [core.int])); 360 isSubtype(getType(C), dart.functionType(C, [core.int]));
361 isSubtype(getType(C), dart.functionType(C, [core.String]), false); 361 isSubtype(getType(C), dart.functionType(C, [core.String]), false);
362 isSubtype(getType(C, 'C'), dart.functionType(C, [core.int])); 362 isSubtype(getType(C, 'new'), dart.functionType(C, [core.int]));
363 isSubtype(getType(C, 'C'), dart.functionType(C, [core.String]), false); 363 isSubtype(getType(C, 'new'), dart.functionType(C, [core.String]), false);
364 isSubtype(getType(C, 'named'), dart.functionType(C, [core.int, core.int])) ; 364 isSubtype(getType(C, 'named'), dart.functionType(C, [core.int, core.int])) ;
365 isSubtype(getType(C, 'named'), 365 isSubtype(getType(C, 'named'),
366 dart.functionType(C, [core.int, core.String]), false); 366 dart.functionType(C, [core.int, core.String]), false);
367 }); 367 });
368 368
369 test('generic and inheritance', () => { 369 test('generic and inheritance', () => {
370 let aaraw = new AA(); 370 let aaraw = new AA();
371 let aarawtype = getReifiedType(aaraw); 371 let aarawtype = getReifiedType(aaraw);
372 let aadynamic = new (AA$(dynamic, dynamic))(); 372 let aadynamic = new (AA$(dynamic, dynamic))();
373 let aadynamictype = getReifiedType(aadynamic); 373 let aadynamictype = getReifiedType(aadynamic);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 }); 504 });
505 505
506 test('dcall', () => { 506 test('dcall', () => {
507 function dd2d(x, y) {return x}; 507 function dd2d(x, y) {return x};
508 dart.fn(dd2d); 508 dart.fn(dd2d);
509 function ii2i(x, y) {return x}; 509 function ii2i(x, y) {return x};
510 dart.fn(ii2i, dart.definiteFunctionType(core.int, [core.int, core.int])); 510 dart.fn(ii2i, dart.definiteFunctionType(core.int, [core.int, core.int]));
511 function ii_2i(x, y) {return x}; 511 function ii_2i(x, y) {return x};
512 dart.fn(ii_2i, dart.definiteFunctionType(core.int, [core.int], [core.int]) ); 512 dart.fn(ii_2i, dart.definiteFunctionType(core.int, [core.int], [core.int]) );
513 function i_i2i(x, opts) {return x}; 513 function i_i2i(x, opts) {return x};
514 dart.fn(i_i2i, 514 dart.fn(i_i2i,
515 dart.definiteFunctionType(core.int, [core.int], {extra: core.int}) ); 515 dart.definiteFunctionType(core.int, [core.int], {extra: core.int}) );
516 516
517 assert.equal(dart.dcall(dd2d, 0, 1), 0); 517 assert.equal(dart.dcall(dd2d, 0, 1), 0);
518 assert.equal(dart.dcall(dd2d, "hello", "world"), "hello"); 518 assert.equal(dart.dcall(dd2d, "hello", "world"), "hello");
519 assert.throws(() => dart.dcall(dd2d, 0)); 519 assert.throws(() => dart.dcall(dd2d, 0));
520 assert.throws(() => dart.dcall(dd2d, 0, 1, 2)); 520 assert.throws(() => dart.dcall(dd2d, 0, 1, 2));
521 assert.throws(() => dart.dcall(dd2d, 0, 1, {extra : 3})); 521 assert.throws(() => dart.dcall(dd2d, 0, 1, {extra : 3}));
522 // This should throw but currently doesn't. 522 // This should throw but currently doesn't.
523 // assert.throws(() => dart.dcall(dd2d, 0, {extra:3})); 523 // assert.throws(() => dart.dcall(dd2d, 0, {extra:3}));
524 524
(...skipping 10 matching lines...) Expand all
535 assert.throws(() => dart.dcall(i_i2i, 0, 1)); 535 assert.throws(() => dart.dcall(i_i2i, 0, 1));
536 assert.throws(() => dart.dcall(i_i2i, "hello", "world")); 536 assert.throws(() => dart.dcall(i_i2i, "hello", "world"));
537 assert.equal(dart.dcall(i_i2i, 0), 0); 537 assert.equal(dart.dcall(i_i2i, 0), 0);
538 assert.throws(() => dart.dcall(i_i2i, 0, 1, 2)); 538 assert.throws(() => dart.dcall(i_i2i, 0, 1, 2));
539 assert.equal(dart.dcall(i_i2i, 0, {extra: 3}), 0); 539 assert.equal(dart.dcall(i_i2i, 0, {extra: 3}), 0);
540 }); 540 });
541 541
542 test('dsend', () => { 542 test('dsend', () => {
543 class Tester extends core.Object { 543 class Tester extends core.Object {
544 new() { 544 new() {
545 this.f = dart.fn(x => x, 545 this.f = dart.fn(x => x,
546 dart.definiteFunctionType(core.int, [core.int])); 546 dart.definiteFunctionType(core.int, [core.int]));
547 this.me = this; 547 this.me = this;
548 } 548 }
549 m(x, y) {return x;} 549 m(x, y) {return x;}
550 call(x) {return x;} 550 call(x) {return x;}
551 static s(x, y) { return x;} 551 static s(x, y) { return x;}
552 } 552 }
553 dart.setSignature(Tester, { 553 dart.setSignature(Tester, {
554 methods: () => ({ 554 methods: () => ({
555 m: dart.definiteFunctionType(core.int, [core.int, core.int]), 555 m: dart.definiteFunctionType(core.int, [core.int, core.int]),
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 613
614 // Set the type eagerly 614 // Set the type eagerly
615 function ii2i(x, y) {return x}; 615 function ii2i(x, y) {return x};
616 dart.fn(ii2i, dart.definiteFunctionType(core.int, [core.int, core.int])); 616 dart.fn(ii2i, dart.definiteFunctionType(core.int, [core.int, core.int]));
617 checkType(ii2i, dart.functionType(core.int, 617 checkType(ii2i, dart.functionType(core.int,
618 [core.int, core.int])); 618 [core.int, core.int]));
619 619
620 // Set the type lazily 620 // Set the type lazily
621 function ss2s(x, y) {return x}; 621 function ss2s(x, y) {return x};
622 var coreString; 622 var coreString;
623 dart.lazyFn(ss2s, 623 dart.lazyFn(ss2s,
624 () => dart.definiteFunctionType(coreString, 624 () => dart.definiteFunctionType(coreString,
625 [coreString, coreString])); 625 [coreString, coreString]));
626 coreString = core.String; 626 coreString = core.String;
627 checkType(ss2s, dart.functionType(core.String, 627 checkType(ss2s, dart.functionType(core.String,
628 [core.String, core.String])); 628 [core.String, core.String]));
629 629
630 // Optional types 630 // Optional types
631 function ii_2i(x, y) {return x}; 631 function ii_2i(x, y) {return x};
632 dart.fn(ii_2i, dart.definiteFunctionType(core.int, [core.int], [core.int]) ); 632 dart.fn(ii_2i, dart.definiteFunctionType(core.int, [core.int], [core.int]) );
633 checkType(ii_2i, dart.functionType(core.int, [core.int], 633 checkType(ii_2i, dart.functionType(core.int, [core.int],
634 [core.int])); 634 [core.int]));
635 checkType(ii_2i, dart.functionType(core.int, [core.int, 635 checkType(ii_2i, dart.functionType(core.int, [core.int,
636 core.int])); 636 core.int]));
637 checkType(ii_2i, dart.functionType(core.int, [], [core.int, 637 checkType(ii_2i, dart.functionType(core.int, [], [core.int,
638 core.int]), 638 core.int]),
639 false); 639 false);
640 checkType(ii_2i, dart.functionType(core.int, [core.int], 640 checkType(ii_2i, dart.functionType(core.int, [core.int],
641 {extra: core.int}), false); 641 {extra: core.int}), false);
642 642
643 // Named types 643 // Named types
644 function i_i2i(x, opts) {return x}; 644 function i_i2i(x, opts) {return x};
645 dart.fn(i_i2i, dart.definiteFunctionType(core.int, [core.int], 645 dart.fn(i_i2i, dart.definiteFunctionType(core.int, [core.int],
646 {extra: core.int})); 646 {extra: core.int}));
647 checkType(i_i2i, dart.functionType(core.int, [core.int], 647 checkType(i_i2i, dart.functionType(core.int, [core.int],
648 {extra: core.int})); 648 {extra: core.int}));
649 checkType(i_i2i, dart.functionType(core.int, 649 checkType(i_i2i, dart.functionType(core.int,
650 [core.int, core.int]), false); 650 [core.int, core.int]), false);
651 checkType(i_i2i, dart.functionType(core.int, [core.int], {})); 651 checkType(i_i2i, dart.functionType(core.int, [core.int], {}));
652 checkType(i_i2i, 652 checkType(i_i2i,
653 dart.functionType(core.int, [], {extra: core.int, 653 dart.functionType(core.int, [], {extra: core.int,
654 also: core.int}), false); 654 also: core.int}), false);
655 checkType(i_i2i, 655 checkType(i_i2i,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 class M2 { 730 class M2 {
731 m(x) {return x;} 731 m(x) {return x;}
732 }; 732 };
733 dart.setSignature(M2, { 733 dart.setSignature(M2, {
734 methods: () => ({ 734 methods: () => ({
735 m: dart.definiteFunctionType(core.Object, [core.int]), 735 m: dart.definiteFunctionType(core.Object, [core.int]),
736 }) 736 })
737 }); 737 });
738 738
739 class O extends dart.mixin(Base, M1, M2) { 739 class O extends dart.mixin(Base, M1, M2) {
740 O() {}; 740 new() {};
741 }; 741 };
742 dart.setSignature(O, {}); 742 dart.setSignature(O, {});
743 var obj = new O(); 743 var obj = new O();
744 var m = dart.bind(obj, 'm'); 744 var m = dart.bind(obj, 'm');
745 checkType(m, dart.functionType(core.Object, [core.int])); 745 checkType(m, dart.functionType(core.Object, [core.int]));
746 checkType(m, dart.functionType(core.int, [core.int]), false, true); 746 checkType(m, dart.functionType(core.int, [core.int]), false, true);
747 747
748 // Test inherited signatures 748 // Test inherited signatures
749 class P extends O { 749 class P extends O {
750 P() {}; 750 new() {};
751 m(x) {return x;}; 751 m(x) {return x;};
752 }; 752 };
753 dart.setSignature(P, {}); 753 dart.setSignature(P, {});
754 var obj = new P(); 754 var obj = new P();
755 var m = dart.bind(obj, 'm'); 755 var m = dart.bind(obj, 'm');
756 checkType(m, dart.functionType(core.Object, [core.int])); 756 checkType(m, dart.functionType(core.Object, [core.int]));
757 checkType(m, dart.functionType(core.int, [core.int]), false, true); 757 checkType(m, dart.functionType(core.int, [core.int]), false, true);
758 }); 758 });
759 759
760 test('Object members', () => { 760 test('Object members', () => {
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 list[0] = 42; 1177 list[0] = 42;
1178 assert.throws(() => list.add(42)); 1178 assert.throws(() => list.add(42));
1179 }); 1179 });
1180 1180
1181 test('toString on ES Symbol', () => { 1181 test('toString on ES Symbol', () => {
1182 let sym = Symbol('_foobar'); 1182 let sym = Symbol('_foobar');
1183 assert.equal(dart.toString(sym), 'Symbol(_foobar)'); 1183 assert.equal(dart.toString(sym), 'Symbol(_foobar)');
1184 }); 1184 });
1185 }); 1185 });
1186 }); 1186 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698