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

Side by Side Diff: tests/compiler/dart2js/backend_dart/dart_printer_test.dart

Issue 925943002: Refactor SourceFile, SourceFileProvider and SourceLocation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 5 years, 10 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library dart_printer_test; 5 library dart_printer_test;
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 import 'package:compiler/src/constants/values.dart'; 8 import 'package:compiler/src/constants/values.dart';
9 import 'package:compiler/src/dart_backend/backend_ast_nodes.dart'; 9 import 'package:compiler/src/dart_backend/backend_ast_nodes.dart';
10 import 'package:compiler/src/scanner/scannerlib.dart'; 10 import 'package:compiler/src/scanner/scannerlib.dart';
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 } 651 }
652 } 652 }
653 else { 653 else {
654 if (x != y) { 654 if (x != y) {
655 throw new Error(); 655 throw new Error();
656 } 656 }
657 } 657 }
658 } 658 }
659 659
660 Expression parseExpression(String code) { 660 Expression parseExpression(String code) {
661 SourceFile file = new StringSourceFile('', code); 661 SourceFile file = new StringSourceFile.fromName('', code);
662 Scanner scan = new Scanner(file); 662 Scanner scan = new Scanner(file);
663 Token tok = scan.tokenize(); 663 Token tok = scan.tokenize();
664 AstBuilder builder = new AstBuilder(); 664 AstBuilder builder = new AstBuilder();
665 Parser parser = new Parser(builder); 665 Parser parser = new Parser(builder);
666 tok = parser.parseExpression(tok); 666 tok = parser.parseExpression(tok);
667 if (builder.stack.length != 1 || tok.kind != EOF_TOKEN) { 667 if (builder.stack.length != 1 || tok.kind != EOF_TOKEN) {
668 throw "Parse error in $code"; 668 throw "Parse error in $code";
669 } 669 }
670 return builder.pop(); 670 return builder.pop();
671 } 671 }
672 Statement parseStatement(String code) { 672 Statement parseStatement(String code) {
673 SourceFile file = new StringSourceFile('', code); 673 SourceFile file = new StringSourceFile.fromName('', code);
674 Scanner scan = new Scanner(file); 674 Scanner scan = new Scanner(file);
675 Token tok = scan.tokenize(); 675 Token tok = scan.tokenize();
676 AstBuilder builder = new AstBuilder(); 676 AstBuilder builder = new AstBuilder();
677 Parser parser = new Parser(builder); 677 Parser parser = new Parser(builder);
678 tok = parser.parseStatement(tok); 678 tok = parser.parseStatement(tok);
679 if (builder.stack.length != 1 || tok.kind != EOF_TOKEN) { 679 if (builder.stack.length != 1 || tok.kind != EOF_TOKEN) {
680 throw "Parse error in $code"; 680 throw "Parse error in $code";
681 } 681 }
682 return builder.pop(); 682 return builder.pop();
683 } 683 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 void checkExpression(String code, [String expected="", String expected2=""]) { 723 void checkExpression(String code, [String expected="", String expected2=""]) {
724 checkFn(code, expected, parseExpression, unparseExpression); 724 checkFn(code, expected, parseExpression, unparseExpression);
725 checkFn(code, expected2, parseExpression, frontUnparseExpression); 725 checkFn(code, expected2, parseExpression, frontUnparseExpression);
726 } 726 }
727 void checkStatement(String code, [String expected="", String expected2=""]) { 727 void checkStatement(String code, [String expected="", String expected2=""]) {
728 checkFn(code, expected, parseStatement, unparseStatement); 728 checkFn(code, expected, parseStatement, unparseStatement);
729 checkFn(code, expected2, parseStatement, frontUnparseStatement); 729 checkFn(code, expected2, parseStatement, frontUnparseStatement);
730 } 730 }
731 731
732 void debugTokens(String code) { 732 void debugTokens(String code) {
733 SourceFile file = new StringSourceFile('', code); 733 SourceFile file = new StringSourceFile.fromName('', code);
734 Scanner scan = new Scanner(file); 734 Scanner scan = new Scanner(file);
735 Token tok = scan.tokenize(); 735 Token tok = scan.tokenize();
736 while (tok.next != tok) { 736 while (tok.next != tok) {
737 print(tok.toString()); 737 print(tok.toString());
738 tok = tok.next; 738 tok = tok.next;
739 } 739 }
740 } 740 }
741 741
742 void main() { 742 void main() {
743 // To check if these tests are effective, one should manually alter 743 // To check if these tests are effective, one should manually alter
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 checkStatement("do while(x); while (y);"); 968 checkStatement("do while(x); while (y);");
969 checkStatement("{do; while(x); while (y);}"); 969 checkStatement("{do; while(x); while (y);}");
970 970
971 checkStatement('switch(x) { case 1: case 2: return y; }'); 971 checkStatement('switch(x) { case 1: case 2: return y; }');
972 checkStatement('switch(x) { default: return y; }'); 972 checkStatement('switch(x) { default: return y; }');
973 checkStatement('switch(x) { case 1: x=y; default: return y; }'); 973 checkStatement('switch(x) { case 1: x=y; default: return y; }');
974 checkStatement('switch(x) { case 1: x=y; y=z; break; default: return y; }'); 974 checkStatement('switch(x) { case 1: x=y; y=z; break; default: return y; }');
975 975
976 } 976 }
977 977
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698