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

Side by Side Diff: pkg/analyzer/test/generated/element_test.dart

Issue 489173002: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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.element_test; 8 library engine.element_test;
9 9
10 import 'package:analyzer/src/generated/java_core.dart'; 10 import 'package:analyzer/src/generated/java_core.dart';
(...skipping 4355 matching lines...) Expand 10 before | Expand all | Expand 10 after
4366 runJUnitTest(__test, __test.test_substitute_equal); 4366 runJUnitTest(__test, __test.test_substitute_equal);
4367 }); 4367 });
4368 _ut.test('test_substitute_notEqual', () { 4368 _ut.test('test_substitute_notEqual', () {
4369 final __test = new TypeParameterTypeImplTest(); 4369 final __test = new TypeParameterTypeImplTest();
4370 runJUnitTest(__test, __test.test_substitute_notEqual); 4370 runJUnitTest(__test, __test.test_substitute_notEqual);
4371 }); 4371 });
4372 }); 4372 });
4373 } 4373 }
4374 } 4374 }
4375 4375
4376 class UnionTypeImplTest extends EngineTestCase {
4377 ClassElement _classA;
4378
4379 InterfaceType _typeA;
4380
4381 ClassElement _classB;
4382
4383 InterfaceType _typeB;
4384
4385 DartType _uA;
4386
4387 DartType _uB;
4388
4389 DartType _uAB;
4390
4391 DartType _uBA;
4392
4393 List<DartType> _us;
4394
4395 void fail_isSubtypeOf_element() {
4396 // Elements of union are sub types
4397 JUnitTestCase.assertTrue(_typeA.isSubtypeOf(_uAB));
4398 JUnitTestCase.assertTrue(_typeB.isSubtypeOf(_uAB));
4399 }
4400
4401 void fail_isSubtypeOf_reflexivity() {
4402 for (DartType u in _us) {
4403 JUnitTestCase.assertTrue(u.isSubtypeOf(u));
4404 }
4405 }
4406
4407 void fail_toString_pair() {
4408 DartType u = UnionTypeImpl.union([_typeA, _typeB]);
4409 String s = u.toString();
4410 JUnitTestCase.assertTrue(s == "{A,B}" || s == "{B,A}");
4411 }
4412
4413 void test_emptyUnionsNotAllowed() {
4414 try {
4415 UnionTypeImpl.union([]);
4416 } on IllegalArgumentException catch (e) {
4417 return;
4418 }
4419 JUnitTestCase.fail("Expected illegal argument exception.");
4420 }
4421
4422 void test_equality_beingASubtypeOfAnElementIsNotSufficient() {
4423 // Non-equal if some elements are different
4424 JUnitTestCase.assertFalse(_uAB == _uA);
4425 }
4426
4427 void test_equality_insertionOrderDoesntMatter() {
4428 // Insertion order doesn't matter, only sets of elements
4429 JUnitTestCase.assertTrue(_uAB == _uBA);
4430 JUnitTestCase.assertTrue(_uBA == _uAB);
4431 }
4432
4433 void test_equality_reflexivity() {
4434 for (DartType u in _us) {
4435 JUnitTestCase.assertTrue(u == u);
4436 }
4437 }
4438
4439 void test_equality_singletonsCollapse() {
4440 JUnitTestCase.assertTrue(_typeA == _uA);
4441 JUnitTestCase.assertTrue(_uA == _typeA);
4442 }
4443
4444 void test_isSubtypeOf_allElementsOnLHSAreSubtypesOfSomeElementOnRHS() {
4445 // Unions are subtypes when all elements are subtypes
4446 JUnitTestCase.assertTrue(_uAB.isSubtypeOf(_uA));
4447 JUnitTestCase.assertTrue(_uAB.isSubtypeOf(_typeA));
4448 }
4449
4450 void test_isSubtypeOf_notSubtypeOfAnyElement() {
4451 // Types that are not subtypes of elements are not subtypes
4452 JUnitTestCase.assertFalse(_typeA.isSubtypeOf(_uB));
4453 }
4454
4455 void test_isSubtypeOf_someElementOnLHSIsNotASubtypeOfAnyElementOnRHS() {
4456 // Unions are not subtypes when some element is not a subtype
4457 JUnitTestCase.assertFalse(_uAB.isSubtypeOf(_uB));
4458 JUnitTestCase.assertFalse(_uAB.isSubtypeOf(_typeB));
4459 }
4460
4461 void test_isSubtypeOf_subtypeOfSomeElement() {
4462 // Subtypes of elements are sub types
4463 JUnitTestCase.assertTrue(_typeB.isSubtypeOf(_uA));
4464 }
4465
4466 void test_nestedUnionsCollapse() {
4467 UnionType u = UnionTypeImpl.union([_uAB, _typeA]) as UnionType;
4468 for (DartType t in u.elements) {
4469 if (t is UnionType) {
4470 JUnitTestCase.fail("Expected only non-union types but found ${t}!");
4471 }
4472 }
4473 }
4474
4475 void test_noLossage() {
4476 UnionType u = UnionTypeImpl.union([_typeA, _typeB, _typeB, _typeA, _typeB, _ typeB]) as UnionType;
4477 Set<DartType> elements = u.elements;
4478 JUnitTestCase.assertTrue(elements.contains(_typeA));
4479 JUnitTestCase.assertTrue(elements.contains(_typeB));
4480 JUnitTestCase.assertTrue(elements.length == 2);
4481 }
4482
4483 void test_toString_singleton() {
4484 // Singleton unions collapse to the the single type.
4485 JUnitTestCase.assertEquals("A", _uA.toString());
4486 }
4487
4488 @override
4489 void setUp() {
4490 super.setUp();
4491 _classA = ElementFactory.classElement2("A", []);
4492 _typeA = _classA.type;
4493 _classB = ElementFactory.classElement("B", _typeA, []);
4494 _typeB = _classB.type;
4495 _uA = UnionTypeImpl.union([_typeA]);
4496 _uB = UnionTypeImpl.union([_typeB]);
4497 _uAB = UnionTypeImpl.union([_typeA, _typeB]);
4498 _uBA = UnionTypeImpl.union([_typeB, _typeA]);
4499 _us = <DartType> [_uA, _uB, _uAB, _uBA];
4500 }
4501
4502 static dartSuite() {
4503 _ut.group('UnionTypeImplTest', () {
4504 _ut.test('test_emptyUnionsNotAllowed', () {
4505 final __test = new UnionTypeImplTest();
4506 runJUnitTest(__test, __test.test_emptyUnionsNotAllowed);
4507 });
4508 _ut.test('test_equality_beingASubtypeOfAnElementIsNotSufficient', () {
4509 final __test = new UnionTypeImplTest();
4510 runJUnitTest(__test, __test.test_equality_beingASubtypeOfAnElementIsNotS ufficient);
4511 });
4512 _ut.test('test_equality_insertionOrderDoesntMatter', () {
4513 final __test = new UnionTypeImplTest();
4514 runJUnitTest(__test, __test.test_equality_insertionOrderDoesntMatter);
4515 });
4516 _ut.test('test_equality_reflexivity', () {
4517 final __test = new UnionTypeImplTest();
4518 runJUnitTest(__test, __test.test_equality_reflexivity);
4519 });
4520 _ut.test('test_equality_singletonsCollapse', () {
4521 final __test = new UnionTypeImplTest();
4522 runJUnitTest(__test, __test.test_equality_singletonsCollapse);
4523 });
4524 _ut.test('test_isSubtypeOf_allElementsOnLHSAreSubtypesOfSomeElementOnRHS', () {
4525 final __test = new UnionTypeImplTest();
4526 runJUnitTest(__test, __test.test_isSubtypeOf_allElementsOnLHSAreSubtypes OfSomeElementOnRHS);
4527 });
4528 _ut.test('test_isSubtypeOf_notSubtypeOfAnyElement', () {
4529 final __test = new UnionTypeImplTest();
4530 runJUnitTest(__test, __test.test_isSubtypeOf_notSubtypeOfAnyElement);
4531 });
4532 _ut.test('test_isSubtypeOf_someElementOnLHSIsNotASubtypeOfAnyElementOnRHS' , () {
4533 final __test = new UnionTypeImplTest();
4534 runJUnitTest(__test, __test.test_isSubtypeOf_someElementOnLHSIsNotASubty peOfAnyElementOnRHS);
4535 });
4536 _ut.test('test_isSubtypeOf_subtypeOfSomeElement', () {
4537 final __test = new UnionTypeImplTest();
4538 runJUnitTest(__test, __test.test_isSubtypeOf_subtypeOfSomeElement);
4539 });
4540 _ut.test('test_nestedUnionsCollapse', () {
4541 final __test = new UnionTypeImplTest();
4542 runJUnitTest(__test, __test.test_nestedUnionsCollapse);
4543 });
4544 _ut.test('test_noLossage', () {
4545 final __test = new UnionTypeImplTest();
4546 runJUnitTest(__test, __test.test_noLossage);
4547 });
4548 _ut.test('test_toString_singleton', () {
4549 final __test = new UnionTypeImplTest();
4550 runJUnitTest(__test, __test.test_toString_singleton);
4551 });
4552 });
4553 }
4554 }
4555
4376 class VoidTypeImplTest extends EngineTestCase { 4556 class VoidTypeImplTest extends EngineTestCase {
4377 /** 4557 /**
4378 * Reference {code VoidTypeImpl.getInstance()}. 4558 * Reference {code VoidTypeImpl.getInstance()}.
4379 */ 4559 */
4380 DartType _voidType = VoidTypeImpl.instance; 4560 DartType _voidType = VoidTypeImpl.instance;
4381 4561
4382 void test_isMoreSpecificThan_void_A() { 4562 void test_isMoreSpecificThan_void_A() {
4383 ClassElement classA = ElementFactory.classElement2("A", []); 4563 ClassElement classA = ElementFactory.classElement2("A", []);
4384 JUnitTestCase.assertFalse(_voidType.isMoreSpecificThan(classA.type)); 4564 JUnitTestCase.assertFalse(_voidType.isMoreSpecificThan(classA.type));
4385 } 4565 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
4442 }); 4622 });
4443 } 4623 }
4444 } 4624 }
4445 4625
4446 main() { 4626 main() {
4447 ElementKindTest.dartSuite(); 4627 ElementKindTest.dartSuite();
4448 AngularPropertyKindTest.dartSuite(); 4628 AngularPropertyKindTest.dartSuite();
4449 FunctionTypeImplTest.dartSuite(); 4629 FunctionTypeImplTest.dartSuite();
4450 InterfaceTypeImplTest.dartSuite(); 4630 InterfaceTypeImplTest.dartSuite();
4451 TypeParameterTypeImplTest.dartSuite(); 4631 TypeParameterTypeImplTest.dartSuite();
4632 UnionTypeImplTest.dartSuite();
4452 VoidTypeImplTest.dartSuite(); 4633 VoidTypeImplTest.dartSuite();
4453 ClassElementImplTest.dartSuite(); 4634 ClassElementImplTest.dartSuite();
4454 CompilationUnitElementImplTest.dartSuite(); 4635 CompilationUnitElementImplTest.dartSuite();
4455 ElementLocationImplTest.dartSuite(); 4636 ElementLocationImplTest.dartSuite();
4456 ElementImplTest.dartSuite(); 4637 ElementImplTest.dartSuite();
4457 HtmlElementImplTest.dartSuite(); 4638 HtmlElementImplTest.dartSuite();
4458 LibraryElementImplTest.dartSuite(); 4639 LibraryElementImplTest.dartSuite();
4459 MultiplyDefinedElementImplTest.dartSuite(); 4640 MultiplyDefinedElementImplTest.dartSuite();
4460 } 4641 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/all_the_rest.dart ('k') | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698