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

Side by Side Diff: tests/compiler/dart2js/type_checker_test.dart

Issue 10911007: Rename Type to DartType to avoid conflicts with the class Type in the core library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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("../../../lib/compiler/implementation/leg.dart"); 5 #import("../../../lib/compiler/implementation/leg.dart");
6 #import("../../../lib/compiler/implementation/elements/elements.dart"); 6 #import("../../../lib/compiler/implementation/elements/elements.dart");
7 #import("../../../lib/compiler/implementation/tree/tree.dart"); 7 #import("../../../lib/compiler/implementation/tree/tree.dart");
8 #import('../../../lib/compiler/implementation/scanner/scannerlib.dart'); 8 #import('../../../lib/compiler/implementation/scanner/scannerlib.dart');
9 #import("../../../lib/compiler/implementation/util/util.dart"); 9 #import("../../../lib/compiler/implementation/util/util.dart");
10 #import("mock_compiler.dart"); 10 #import("mock_compiler.dart");
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 LibraryElement library = mockLibrary(compiler, script); 346 LibraryElement library = mockLibrary(compiler, script);
347 compiler.parseScript(script, library); 347 compiler.parseScript(script, library);
348 ClassElement foo = library.find(const SourceString("Foo")); 348 ClassElement foo = library.find(const SourceString("Foo"));
349 analyzeIn(foo, "{ int i = this; }", MessageKind.NOT_ASSIGNABLE); 349 analyzeIn(foo, "{ int i = this; }", MessageKind.NOT_ASSIGNABLE);
350 analyzeIn(foo, "{ Object o = this; }"); 350 analyzeIn(foo, "{ Object o = this; }");
351 analyzeIn(foo, "{ Foo f = this; }"); 351 analyzeIn(foo, "{ Foo f = this; }");
352 } 352 }
353 353
354 testFunctionSubtyping() { 354 testFunctionSubtyping() {
355 // Checks that the type (in1 -> out1) is a subtype of (in2 -> out2). 355 // Checks that the type (in1 -> out1) is a subtype of (in2 -> out2).
356 bool isSubtype(List<Type> in1, Type out1, List<Type> in2, Type out2) { 356 bool isSubtype(List<DartType> in1, Type out1, List<Type> in2, Type out2) {
357 return compiler.types.isSubtype( 357 return compiler.types.isSubtype(
358 new FunctionType(out1, new Link<Type>.fromList(in1), null), 358 new FunctionType(out1, new Link<DartType>.fromList(in1), null),
359 new FunctionType(out2, new Link<Type>.fromList(in2), null)); 359 new FunctionType(out2, new Link<DartType>.fromList(in2), null));
360 } 360 }
361 Expect.isTrue(isSubtype([], intType, [], intType)); 361 Expect.isTrue(isSubtype([], intType, [], intType));
362 Expect.isTrue(isSubtype([], intType, [], objectType)); 362 Expect.isTrue(isSubtype([], intType, [], objectType));
363 Expect.isFalse(isSubtype([], intType, [], doubleType)); 363 Expect.isFalse(isSubtype([], intType, [], doubleType));
364 Expect.isTrue(isSubtype([intType], intType, [intType], intType)); 364 Expect.isTrue(isSubtype([intType], intType, [intType], intType));
365 Expect.isTrue(isSubtype([objectType], intType, [intType], objectType)); 365 Expect.isTrue(isSubtype([objectType], intType, [intType], objectType));
366 Expect.isFalse(isSubtype([intType], intType, [doubleType], intType)); 366 Expect.isFalse(isSubtype([intType], intType, [doubleType], intType));
367 Expect.isFalse(isSubtype([intType], intType, [intType, intType], intType)); 367 Expect.isFalse(isSubtype([intType], intType, [intType, intType], intType));
368 Expect.isFalse(isSubtype([intType, intType], intType, [intType], intType)); 368 Expect.isFalse(isSubtype([intType, intType], intType, [intType], intType));
369 } 369 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 Node node = listener.popNode(); 465 Node node = listener.popNode();
466 classElement.ensureResolved(compiler); 466 classElement.ensureResolved(compiler);
467 TreeElements elements = compiler.resolveNodeStatement(node, classElement); 467 TreeElements elements = compiler.resolveNodeStatement(node, classElement);
468 TypeCheckerVisitor checker = new TypeCheckerVisitor(compiler, elements, 468 TypeCheckerVisitor checker = new TypeCheckerVisitor(compiler, elements,
469 types); 469 types);
470 compiler.clearWarnings(); 470 compiler.clearWarnings();
471 checker.currentClass = classElement; 471 checker.currentClass = classElement;
472 checker.analyze(node); 472 checker.analyze(node);
473 compareWarningKinds(text, expectedWarnings, compiler.warnings); 473 compareWarningKinds(text, expectedWarnings, compiler.warnings);
474 } 474 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698