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

Side by Side Diff: frog/tests/leg/src/TypeCheckerTest.dart

Issue 8974014: Resolve initializers in constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add tests. Created 9 years 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("../../../leg/leg.dart"); 5 #import("../../../leg/leg.dart");
6 #import("../../../leg/elements/elements.dart"); 6 #import("../../../leg/elements/elements.dart");
7 #import("../../../leg/tree/tree.dart"); 7 #import("../../../leg/tree/tree.dart");
8 #import('../../../leg/scanner/scannerlib.dart'); 8 #import('../../../leg/scanner/scannerlib.dart');
9 #import("../../../leg/util/util.dart"); 9 #import("../../../leg/util/util.dart");
10 #import("mock_compiler.dart"); 10 #import("mock_compiler.dart");
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 TreeElements elements = compiler.resolveNodeStatement(node); 380 TreeElements elements = compiler.resolveNodeStatement(node);
381 TypeCheckerVisitor checker = new TypeCheckerVisitor(compiler, elements, 381 TypeCheckerVisitor checker = new TypeCheckerVisitor(compiler, elements,
382 types); 382 types);
383 compiler.clearWarnings(); 383 compiler.clearWarnings();
384 checker.analyze(node); 384 checker.analyze(node);
385 compareWarningKinds(text, expectedWarnings, compiler.warnings); 385 compareWarningKinds(text, expectedWarnings, compiler.warnings);
386 386
387 compiler.universe = universe; 387 compiler.universe = universe;
388 } 388 }
389 389
390 void compareWarningKinds(String text, expectedWarnings, foundWarnings) {
391 var fail = (message) => Expect.fail('$text: $message');
392 Iterator<MessageKind> expected = expectedWarnings.iterator();
393 Iterator<WarningMessage> found = foundWarnings.iterator();
394 while (expected.hasNext() && found.hasNext()) {
395 Expect.equals(expected.next(), found.next().message.kind);
396 }
397 if (expected.hasNext()) {
398 do {
399 print('Expected warning "${expected.next()}" did not occur');
400 } while (expected.hasNext());
401 fail('Too few warnings');
402 }
403 if (found.hasNext()) {
404 do {
405 print('Additional warning "${found.next()}"');
406 } while (found.hasNext());
407 fail('Too many warnings');
408 }
409 }
410
411 class ExtendedUniverse extends Universe { 390 class ExtendedUniverse extends Universe {
412 final Universe base; 391 final Universe base;
413 392
414 ExtendedUniverse(Universe this.base); 393 ExtendedUniverse(Universe this.base);
415 394
416 Element find(SourceString name) { 395 Element find(SourceString name) {
417 Element result = elements[name]; 396 Element result = elements[name];
418 if (result == null) result = base.find(name); 397 if (result == null) result = base.find(name);
419 return result; 398 return result;
420 } 399 }
421 400
422 void define(Element element) { 401 void define(Element element) {
423 assert(base.elements[element.name] == null); 402 assert(base.elements[element.name] == null);
424 super.define(element); 403 super.define(element);
425 } 404 }
426 } 405 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698