| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.resolver_test; | 8 library engine.resolver_test; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 "class C {", | 452 "class C {", |
| 453 " final A a;", | 453 " final A a;", |
| 454 " const C(this.a);", | 454 " const C(this.a);", |
| 455 "}", | 455 "}", |
| 456 "var v = const C(const B());"])); | 456 "var v = const C(const B());"])); |
| 457 resolve(source); | 457 resolve(source); |
| 458 assertNoErrors(source); | 458 assertNoErrors(source); |
| 459 verify([source]); | 459 verify([source]); |
| 460 } | 460 } |
| 461 | 461 |
| 462 void test_fieldFormalParameterAssignableToField_list_dynamic() { |
| 463 // [1, 2, 3] has type List<dynamic>, which is a subtype of List<int>. |
| 464 Source source = addSource(EngineTestCase.createSource([ |
| 465 "class A {", |
| 466 " const A(List<int> x);", |
| 467 "}", |
| 468 "var x = const A(const [1, 2, 3]);"])); |
| 469 resolve(source); |
| 470 assertNoErrors(source); |
| 471 verify([source]); |
| 472 } |
| 473 |
| 474 void test_fieldFormalParameterAssignableToField_list_nonDynamic() { |
| 475 // <int>[1, 2, 3] has type List<int>, which is a subtype of List<num>. |
| 476 Source source = addSource(EngineTestCase.createSource([ |
| 477 "class A {", |
| 478 " const A(List<num> x);", |
| 479 "}", |
| 480 "var x = const A(const <int>[1, 2, 3]);"])); |
| 481 resolve(source); |
| 482 assertNoErrors(source); |
| 483 verify([source]); |
| 484 } |
| 485 |
| 486 void test_fieldFormalParameterAssignableToField_map_dynamic() { |
| 487 // {1: 2} has type Map<dynamic, dynamic>, which is a subtype of |
| 488 // Map<int, int>. |
| 489 Source source = addSource(EngineTestCase.createSource([ |
| 490 "class A {", |
| 491 " const A(Map<int, int> x);", |
| 492 "}", |
| 493 "var x = const A(const {1: 2});"])); |
| 494 resolve(source); |
| 495 assertNoErrors(source); |
| 496 verify([source]); |
| 497 } |
| 498 |
| 499 void test_fieldFormalParameterAssignableToField_map_keyDifferent() { |
| 500 // <int, int>{1: 2} has type Map<int, int>, which is a subtype of |
| 501 // Map<num, int>. |
| 502 Source source = addSource(EngineTestCase.createSource([ |
| 503 "class A {", |
| 504 " const A(Map<num, int> x);", |
| 505 "}", |
| 506 "var x = const A(const <int, int>{1: 2});"])); |
| 507 resolve(source); |
| 508 assertNoErrors(source); |
| 509 verify([source]); |
| 510 } |
| 511 |
| 512 void test_fieldFormalParameterAssignableToField_map_valueDifferent() { |
| 513 // <int, int>{1: 2} has type Map<int, int>, which is a subtype of |
| 514 // Map<int, num>. |
| 515 Source source = addSource(EngineTestCase.createSource([ |
| 516 "class A {", |
| 517 " const A(Map<int, num> x);", |
| 518 "}", |
| 519 "var x = const A(const <int, int>{1: 2});"])); |
| 520 resolve(source); |
| 521 assertNoErrors(source); |
| 522 verify([source]); |
| 523 } |
| 524 |
| 462 void test_fieldFormalParameterAssignableToField_notype() { | 525 void test_fieldFormalParameterAssignableToField_notype() { |
| 463 // If a field is declared without a type, then any value may be assigned to | 526 // If a field is declared without a type, then any value may be assigned to |
| 464 // it. | 527 // it. |
| 465 Source source = addSource(EngineTestCase.createSource([ | 528 Source source = addSource(EngineTestCase.createSource([ |
| 466 "class A {", | 529 "class A {", |
| 467 " final x;", | 530 " final x;", |
| 468 " const A(this.x);", | 531 " const A(this.x);", |
| 469 "}", | 532 "}", |
| 470 "var v = const A(5);"])); | 533 "var v = const A(5);"])); |
| 471 resolve(source); | 534 resolve(source); |
| 472 assertNoErrors(source); | 535 assertNoErrors(source); |
| 473 verify([source]); | 536 verify([source]); |
| 474 } | 537 } |
| 475 | 538 |
| 476 void test_fieldFormalParameterAssignableToField_null() { | 539 void test_fieldFormalParameterAssignableToField_null() { |
| 477 // Null is assignable to anything. | 540 // Null is assignable to anything. |
| 478 Source source = addSource(EngineTestCase.createSource([ | 541 Source source = addSource(EngineTestCase.createSource([ |
| 479 "class A {", | 542 "class A {", |
| 480 " final int x;", | 543 " final int x;", |
| 481 " const A(this.x);", | 544 " const A(this.x);", |
| 482 "}", | 545 "}", |
| 483 "var v = const A(null);"])); | 546 "var v = const A(null);"])); |
| 484 resolve(source); | 547 resolve(source); |
| 485 assertNoErrors(source); | 548 assertNoErrors(source); |
| 486 verify([source]); | 549 verify([source]); |
| 487 } | 550 } |
| 488 | 551 |
| 552 void test_fieldFormalParameterAssignableToField_typeSubstitution() { |
| 553 // foo has the runtime type dynamic -> dynamic, so it should be assignable |
| 554 // to A.f. |
| 555 Source source = addSource(EngineTestCase.createSource([ |
| 556 "class A<T> {", |
| 557 " final T x;", |
| 558 " const A(this.x);", |
| 559 "}", |
| 560 "var v = const A<int>(3);"])); |
| 561 resolve(source); |
| 562 assertNoErrors(source); |
| 563 verify([source]); |
| 564 } |
| 565 |
| 489 void test_fieldFormalParameterAssignableToField_typedef() { | 566 void test_fieldFormalParameterAssignableToField_typedef() { |
| 490 // foo has the runtime type dynamic -> dynamic, so it should be assignable | 567 // foo has the runtime type dynamic -> dynamic, so it should be assignable |
| 491 // to A.f. | 568 // to A.f. |
| 492 Source source = addSource(EngineTestCase.createSource([ | 569 Source source = addSource(EngineTestCase.createSource([ |
| 493 "typedef String Int2String(int x);", | 570 "typedef String Int2String(int x);", |
| 494 "class A {", | 571 "class A {", |
| 495 " final Int2String f;", | 572 " final Int2String f;", |
| 496 " const A(this.f);", | 573 " const A(this.f);", |
| 497 "}", | 574 "}", |
| 498 "foo(x) => 1;" | 575 "foo(x) => 1;" |
| 499 "var v = const A(foo);"])); | 576 "var v = const A(foo);"])); |
| 500 resolve(source); | 577 resolve(source); |
| 501 assertNoErrors(source); | 578 assertNoErrors(source); |
| 502 verify([source]); | 579 verify([source]); |
| 503 } | |
| 504 | |
| 505 void test_fieldFormalParameterAssignableToField_typeSubstitution() { | |
| 506 // foo has the runtime type dynamic -> dynamic, so it should be assignable | |
| 507 // to A.f. | |
| 508 Source source = addSource(EngineTestCase.createSource([ | |
| 509 "class A<T> {", | |
| 510 " final T x;", | |
| 511 " const A(this.x);", | |
| 512 "}", | |
| 513 "var v = const A<int>(3);"])); | |
| 514 resolve(source); | |
| 515 assertNoErrors(source); | |
| 516 verify([source]); | |
| 517 } | 580 } |
| 518 | 581 |
| 519 void test_fieldFormalParameterNotAssignableToField() { | 582 void test_fieldFormalParameterNotAssignableToField() { |
| 520 Source source = addSource(EngineTestCase.createSource([ | 583 Source source = addSource(EngineTestCase.createSource([ |
| 521 "class A {", | 584 "class A {", |
| 522 " final int x;", | 585 " final int x;", |
| 523 " const A(this.x);", | 586 " const A(this.x);", |
| 524 "}", | 587 "}", |
| 525 "var v = const A('foo');"])); | 588 "var v = const A('foo');"])); |
| 526 resolve(source); | 589 resolve(source); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 " final B b;", | 628 " final B b;", |
| 566 " const C(this.b);", | 629 " const C(this.b);", |
| 567 "}", | 630 "}", |
| 568 "var v = const C(const A());"])); | 631 "var v = const C(const A());"])); |
| 569 resolve(source); | 632 resolve(source); |
| 570 assertErrors(source, [ | 633 assertErrors(source, [ |
| 571 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]); | 634 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]); |
| 572 verify([source]); | 635 verify([source]); |
| 573 } | 636 } |
| 574 | 637 |
| 638 void test_fieldFormalParameterNotAssignableToField_list() { |
| 639 // <num>[1, 2, 3] has type List<num>, which is not a subtype of List<int>. |
| 640 Source source = addSource(EngineTestCase.createSource([ |
| 641 "class A {", |
| 642 " const A(List<int> x);", |
| 643 "}", |
| 644 "var x = const A(const <num>[1, 2, 3]);"])); |
| 645 resolve(source); |
| 646 assertErrors(source, [ |
| 647 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]); |
| 648 verify([source]); |
| 649 } |
| 650 |
| 651 void test_fieldFormalParameterNotAssignableToField_map_keyMismatch() { |
| 652 // <num, int>{1: 2} has type Map<num, int>, which is not a subtype of |
| 653 // Map<int, int>. |
| 654 Source source = addSource(EngineTestCase.createSource([ |
| 655 "class A {", |
| 656 " const A(Map<int, int> x);", |
| 657 "}", |
| 658 "var x = const A(const <num, int>{1: 2});"])); |
| 659 resolve(source); |
| 660 assertErrors(source, [ |
| 661 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]); |
| 662 verify([source]); |
| 663 } |
| 664 |
| 665 void test_fieldFormalParameterNotAssignableToField_map_valueMismatch() { |
| 666 // <int, num>{1: 2} has type Map<int, num>, which is not a subtype of |
| 667 // Map<int, int>. |
| 668 Source source = addSource(EngineTestCase.createSource([ |
| 669 "class A {", |
| 670 " const A(Map<int, int> x);", |
| 671 "}", |
| 672 "var x = const A(const <int, num>{1: 2});"])); |
| 673 resolve(source); |
| 674 assertErrors(source, [ |
| 675 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH]); |
| 676 verify([source]); |
| 677 } |
| 678 |
| 575 void test_fieldFormalParameterNotAssignableToField_optional() { | 679 void test_fieldFormalParameterNotAssignableToField_optional() { |
| 576 Source source = addSource(EngineTestCase.createSource([ | 680 Source source = addSource(EngineTestCase.createSource([ |
| 577 "class A {", | 681 "class A {", |
| 578 " final int x;", | 682 " final int x;", |
| 579 " const A([this.x = 'foo']);", | 683 " const A([this.x = 'foo']);", |
| 580 "}", | 684 "}", |
| 581 "var v = const A();"])); | 685 "var v = const A();"])); |
| 582 resolve(source); | 686 resolve(source); |
| 583 assertErrors(source, [ | 687 assertErrors(source, [ |
| 584 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, | 688 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, |
| (...skipping 22638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23223 runReflectiveTests(HintCodeTest); | 23327 runReflectiveTests(HintCodeTest); |
| 23224 runReflectiveTests(MemberMapTest); | 23328 runReflectiveTests(MemberMapTest); |
| 23225 runReflectiveTests(NonErrorResolverTest); | 23329 runReflectiveTests(NonErrorResolverTest); |
| 23226 runReflectiveTests(NonHintCodeTest); | 23330 runReflectiveTests(NonHintCodeTest); |
| 23227 runReflectiveTests(SimpleResolverTest); | 23331 runReflectiveTests(SimpleResolverTest); |
| 23228 runReflectiveTests(StaticTypeWarningCodeTest); | 23332 runReflectiveTests(StaticTypeWarningCodeTest); |
| 23229 runReflectiveTests(StaticWarningCodeTest); | 23333 runReflectiveTests(StaticWarningCodeTest); |
| 23230 runReflectiveTests(StrictModeTest); | 23334 runReflectiveTests(StrictModeTest); |
| 23231 runReflectiveTests(TypePropagationTest); | 23335 runReflectiveTests(TypePropagationTest); |
| 23232 } | 23336 } |
| OLD | NEW |