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

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

Issue 11361190: a === b -> identical(a, b) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 1 month 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
« no previous file with comments | « tests/compiler/dart2js/scanner_test.dart ('k') | tests/compiler/dart2js/type_equals_test.dart » ('j') | 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) 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 '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' 5 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
6 hide SourceString; 6 hide SourceString;
7 import '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t'; 7 import '../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t';
8 import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart'; 8 import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart';
9 import '../../../sdk/lib/_internal/compiler/implementation/util/util.dart'; 9 import '../../../sdk/lib/_internal/compiler/implementation/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
409 } 409 }
410 410
411 DartType analyzeType(String text) { 411 DartType analyzeType(String text) {
412 var node = parseExpression(text); 412 var node = parseExpression(text);
413 TypeCheckerVisitor visitor = 413 TypeCheckerVisitor visitor =
414 new TypeCheckerVisitor(compiler, new TreeElementMapping(null), types); 414 new TypeCheckerVisitor(compiler, new TreeElementMapping(null), types);
415 return visitor.analyze(node); 415 return visitor.analyze(node);
416 } 416 }
417 417
418 analyzeTopLevel(String text, [expectedWarnings]) { 418 analyzeTopLevel(String text, [expectedWarnings]) {
419 if (expectedWarnings === null) expectedWarnings = []; 419 if (expectedWarnings == null) expectedWarnings = [];
420 if (expectedWarnings is !List) expectedWarnings = [expectedWarnings]; 420 if (expectedWarnings is !List) expectedWarnings = [expectedWarnings];
421 421
422 LibraryElement library = mockLibrary(compiler, text); 422 LibraryElement library = mockLibrary(compiler, text);
423 423
424 Link<Element> topLevelElements = parseUnit(text, compiler, library); 424 Link<Element> topLevelElements = parseUnit(text, compiler, library);
425 425
426 for (Link<Element> elements = topLevelElements; 426 for (Link<Element> elements = topLevelElements;
427 !elements.isEmpty; 427 !elements.isEmpty;
428 elements = elements.tail) { 428 elements = elements.tail) {
429 Node node = elements.head.parseNode(compiler); 429 Node node = elements.head.parseNode(compiler);
430 TreeElements mapping = compiler.resolver.resolve(elements.head); 430 TreeElements mapping = compiler.resolver.resolve(elements.head);
431 TypeCheckerVisitor checker = 431 TypeCheckerVisitor checker =
432 new TypeCheckerVisitor(compiler, mapping, types); 432 new TypeCheckerVisitor(compiler, mapping, types);
433 compiler.clearWarnings(); 433 compiler.clearWarnings();
434 checker.analyze(node); 434 checker.analyze(node);
435 compareWarningKinds(text, expectedWarnings, compiler.warnings); 435 compareWarningKinds(text, expectedWarnings, compiler.warnings);
436 } 436 }
437 } 437 }
438 438
439 analyze(String text, [expectedWarnings]) { 439 analyze(String text, [expectedWarnings]) {
440 if (expectedWarnings === null) expectedWarnings = []; 440 if (expectedWarnings == null) expectedWarnings = [];
441 if (expectedWarnings is !List) expectedWarnings = [expectedWarnings]; 441 if (expectedWarnings is !List) expectedWarnings = [expectedWarnings];
442 442
443 Token tokens = scan(text); 443 Token tokens = scan(text);
444 NodeListener listener = new NodeListener(compiler, null); 444 NodeListener listener = new NodeListener(compiler, null);
445 Parser parser = new Parser(listener); 445 Parser parser = new Parser(listener);
446 parser.parseStatement(tokens); 446 parser.parseStatement(tokens);
447 Node node = listener.popNode(); 447 Node node = listener.popNode();
448 Element function = new Element( 448 Element function = new Element(
449 buildSourceString(''), ElementKind.FUNCTION, compiler.mainApp); 449 buildSourceString(''), ElementKind.FUNCTION, compiler.mainApp);
450 TreeElements elements = compiler.resolveNodeStatement(node, function); 450 TreeElements elements = compiler.resolveNodeStatement(node, function);
451 TypeCheckerVisitor checker = new TypeCheckerVisitor(compiler, elements, 451 TypeCheckerVisitor checker = new TypeCheckerVisitor(compiler, elements,
452 types); 452 types);
453 compiler.clearWarnings(); 453 compiler.clearWarnings();
454 checker.analyze(node); 454 checker.analyze(node);
455 compareWarningKinds(text, expectedWarnings, compiler.warnings); 455 compareWarningKinds(text, expectedWarnings, compiler.warnings);
456 } 456 }
457 457
458 analyzeIn(ClassElement classElement, String text, [expectedWarnings]) { 458 analyzeIn(ClassElement classElement, String text, [expectedWarnings]) {
459 if (expectedWarnings === null) expectedWarnings = []; 459 if (expectedWarnings == null) expectedWarnings = [];
460 if (expectedWarnings is !List) expectedWarnings = [expectedWarnings]; 460 if (expectedWarnings is !List) expectedWarnings = [expectedWarnings];
461 461
462 Token tokens = scan(text); 462 Token tokens = scan(text);
463 NodeListener listener = new NodeListener(compiler, null); 463 NodeListener listener = new NodeListener(compiler, null);
464 Parser parser = new Parser(listener); 464 Parser parser = new Parser(listener);
465 parser.parseStatement(tokens); 465 parser.parseStatement(tokens);
466 Node node = listener.popNode(); 466 Node node = listener.popNode();
467 classElement.ensureResolved(compiler); 467 classElement.ensureResolved(compiler);
468 TreeElements elements = compiler.resolveNodeStatement(node, classElement); 468 TreeElements elements = compiler.resolveNodeStatement(node, classElement);
469 TypeCheckerVisitor checker = new TypeCheckerVisitor(compiler, elements, 469 TypeCheckerVisitor checker = new TypeCheckerVisitor(compiler, elements,
470 types); 470 types);
471 compiler.clearWarnings(); 471 compiler.clearWarnings();
472 checker.currentClass = classElement; 472 checker.currentClass = classElement;
473 checker.analyze(node); 473 checker.analyze(node);
474 compareWarningKinds(text, expectedWarnings, compiler.warnings); 474 compareWarningKinds(text, expectedWarnings, compiler.warnings);
475 } 475 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/scanner_test.dart ('k') | tests/compiler/dart2js/type_equals_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698