| OLD | NEW |
| 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 TypeCheckerVisitor checker = new TypeCheckerVisitor(compiler, elements, | 409 TypeCheckerVisitor checker = new TypeCheckerVisitor(compiler, elements, |
| 410 types); | 410 types); |
| 411 compiler.clearWarnings(); | 411 compiler.clearWarnings(); |
| 412 checker.currentClass = classElement; | 412 checker.currentClass = classElement; |
| 413 checker.analyze(node); | 413 checker.analyze(node); |
| 414 compareWarningKinds(text, expectedWarnings, compiler.warnings); | 414 compareWarningKinds(text, expectedWarnings, compiler.warnings); |
| 415 | 415 |
| 416 compiler.universe = universe; | 416 compiler.universe = universe; |
| 417 } | 417 } |
| 418 | 418 |
| 419 void compareWarningKinds(String text, expectedWarnings, foundWarnings) { | |
| 420 var fail = (message) => Expect.fail('$text: $message'); | |
| 421 Iterator<MessageKind> expected = expectedWarnings.iterator(); | |
| 422 Iterator<WarningMessage> found = foundWarnings.iterator(); | |
| 423 while (expected.hasNext() && found.hasNext()) { | |
| 424 Expect.equals(expected.next(), found.next().message.kind); | |
| 425 } | |
| 426 if (expected.hasNext()) { | |
| 427 do { | |
| 428 print('Expected warning "${expected.next()}" did not occur'); | |
| 429 } while (expected.hasNext()); | |
| 430 fail('Too few warnings'); | |
| 431 } | |
| 432 if (found.hasNext()) { | |
| 433 do { | |
| 434 print('Additional warning "${found.next()}"'); | |
| 435 } while (found.hasNext()); | |
| 436 fail('Too many warnings'); | |
| 437 } | |
| 438 } | |
| 439 | |
| 440 class ExtendedUniverse extends Universe { | 419 class ExtendedUniverse extends Universe { |
| 441 final Universe base; | 420 final Universe base; |
| 442 | 421 |
| 443 ExtendedUniverse(Universe this.base); | 422 ExtendedUniverse(Universe this.base); |
| 444 | 423 |
| 445 Element find(SourceString name) { | 424 Element find(SourceString name) { |
| 446 Element result = elements[name]; | 425 Element result = elements[name]; |
| 447 if (result == null) result = base.find(name); | 426 if (result == null) result = base.find(name); |
| 448 return result; | 427 return result; |
| 449 } | 428 } |
| 450 | 429 |
| 451 void define(Element element) { | 430 void define(Element element) { |
| 452 assert(base.elements[element.name] == null); | 431 assert(base.elements[element.name] == null); |
| 453 super.define(element); | 432 super.define(element); |
| 454 } | 433 } |
| 455 } | 434 } |
| OLD | NEW |