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

Side by Side Diff: pkg/kernel/test/class_hierarchy_test.dart

Issue 2924333002: Use ClassHierarchy.applyChanges() in MixinFullResolution. (Closed)
Patch Set: Changes for review comments. Created 3 years, 6 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
« no previous file with comments | « pkg/kernel/lib/transformations/mixin_full_resolution.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:kernel/ast.dart'; 5 import 'package:kernel/ast.dart';
6 import 'package:kernel/class_hierarchy.dart'; 6 import 'package:kernel/class_hierarchy.dart';
7 import 'package:kernel/core_types.dart'; 7 import 'package:kernel/core_types.dart';
8 import 'package:kernel/src/incremental_class_hierarchy.dart'; 8 import 'package:kernel/src/incremental_class_hierarchy.dart';
9 import 'package:kernel/testing/mock_sdk_program.dart'; 9 import 'package:kernel/testing/mock_sdk_program.dart';
10 import 'package:kernel/text/ast_to_text.dart'; 10 import 'package:kernel/text/ast_to_text.dart';
11 import 'package:kernel/type_algebra.dart'; 11 import 'package:kernel/type_algebra.dart';
12 import 'package:test/test.dart'; 12 import 'package:test/test.dart';
13 import 'package:test_reflective_loader/test_reflective_loader.dart'; 13 import 'package:test_reflective_loader/test_reflective_loader.dart';
14 14
15 main() { 15 main() {
16 defineReflectiveSuite(() { 16 defineReflectiveSuite(() {
17 defineReflectiveTests(ClosedWorldClassHierarchyTest); 17 defineReflectiveTests(ClosedWorldClassHierarchyTest);
18 defineReflectiveTests(IncrementalClassHierarchyTest); 18 defineReflectiveTests(IncrementalClassHierarchyTest);
19 }); 19 });
20 } 20 }
21 21
22 @reflectiveTest 22 @reflectiveTest
23 class ClosedWorldClassHierarchyTest extends _ClassHierarchyTest { 23 class ClosedWorldClassHierarchyTest extends _ClassHierarchyTest {
24 ClassHierarchy createClassHierarchy(Program program) { 24 ClassHierarchy createClassHierarchy(Program program) {
25 return new ClosedWorldClassHierarchy(program); 25 return new ClosedWorldClassHierarchy(program);
26 } 26 }
27
28 void test_applyChanges() {
29 var a = addClass(new Class(name: 'A', supertype: objectSuper));
30 addClass(new Class(name: 'B', supertype: a.asThisSupertype));
31
32 _assertTestLibraryText('''
33 class A {}
34 class B extends self::A {}
35 ''');
36
37 // No updated classes, the same hierarchy.
38 expect(hierarchy.applyChanges([]), same(hierarchy));
39
40 // Has updated classes, a new hierarchy.
41 var newHierarchy = hierarchy.applyChanges([a]);
42 expect(newHierarchy, isNot(same(hierarchy)));
43 expect(newHierarchy, new isInstanceOf<ClosedWorldClassHierarchy>());
44 }
27 } 45 }
28 46
29 @reflectiveTest 47 @reflectiveTest
30 class IncrementalClassHierarchyTest extends _ClassHierarchyTest { 48 class IncrementalClassHierarchyTest extends _ClassHierarchyTest {
31 ClassHierarchy createClassHierarchy(Program program) { 49 ClassHierarchy createClassHierarchy(Program program) {
32 return new IncrementalClassHierarchy(); 50 return new IncrementalClassHierarchy();
33 } 51 }
52
53 void test_applyChanges() {
54 var a = addClass(new Class(name: 'A', supertype: objectSuper));
55 addClass(new Class(name: 'B', supertype: a.asThisSupertype));
56
57 _assertTestLibraryText('''
58 class A {}
59 class B extends self::A {}
60 ''');
61
62 // No updated classes, the same hierarchy.
63 expect(hierarchy.applyChanges([]), same(hierarchy));
64
65 // Has updated classes, a new hierarchy.
66 var newHierarchy = hierarchy.applyChanges([a]);
67 expect(newHierarchy, isNot(same(hierarchy)));
68 expect(newHierarchy, new isInstanceOf<IncrementalClassHierarchy>());
69 }
34 } 70 }
35 71
36 abstract class _ClassHierarchyTest { 72 abstract class _ClassHierarchyTest {
37 Program program; 73 Program program;
38 CoreTypes coreTypes; 74 CoreTypes coreTypes;
39 75
40 /// The test library. 76 /// The test library.
41 Library library; 77 Library library;
42 78
43 ClassHierarchy _hierarchy; 79 ClassHierarchy _hierarchy;
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 actualText = actualText.replaceAll(' extends core::Object', ''); 937 actualText = actualText.replaceAll(' extends core::Object', '');
902 938
903 // if (actualText != expectedText) { 939 // if (actualText != expectedText) {
904 // print('-------- Actual --------'); 940 // print('-------- Actual --------');
905 // print(actualText + '------------------------'); 941 // print(actualText + '------------------------');
906 // } 942 // }
907 943
908 expect(actualText, expectedText); 944 expect(actualText, expectedText);
909 } 945 }
910 } 946 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/transformations/mixin_full_resolution.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698