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

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

Issue 1864433004: Repeats and fixes the changes landed & reverted as CL 1789553003. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updates to external dependents Created 4 years, 8 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
« no previous file with comments | « tests/compiler/dart2js/analyze_helper.dart ('k') | tests/compiler/dart2js/bad_loop_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) 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 'dart:mirrors'; 7 import 'dart:mirrors';
8 import 'package:expect/expect.dart'; 8 import 'package:expect/expect.dart';
9 import 'package:compiler/src/constants/values.dart'; 9 import 'package:compiler/src/constants/values.dart';
10 import 'package:compiler/src/dart_backend/backend_ast_nodes.dart'; 10 import 'package:compiler/src/dart_backend/backend_ast_nodes.dart';
11 import 'package:compiler/src/dart_backend/backend_ast_to_frontend_ast.dart' 11 import 'package:compiler/src/dart_backend/backend_ast_to_frontend_ast.dart'
12 show TreePrinter; 12 show TreePrinter;
13 import 'package:compiler/src/diagnostics/diagnostic_listener.dart'; 13 import 'package:compiler/src/diagnostics/diagnostic_listener.dart';
14 import 'package:compiler/src/diagnostics/messages.dart'; 14 import 'package:compiler/src/diagnostics/messages.dart';
15 import 'package:compiler/src/diagnostics/spannable.dart' show Spannable; 15 import 'package:compiler/src/diagnostics/spannable.dart' show Spannable;
16 import 'package:compiler/src/parser/listener.dart'; 16 import 'package:compiler/src/parser/listener.dart';
17 import 'package:compiler/src/parser/parser.dart'; 17 import 'package:compiler/src/parser/parser.dart';
18 import 'package:compiler/src/scanner/scanner.dart'; 18 import 'package:compiler/src/scanner/scanner.dart';
19 import 'package:compiler/src/tokens/token.dart'; 19 import 'package:compiler/src/tokens/token.dart';
20 import 'package:compiler/src/tokens/token_constants.dart'; 20 import 'package:compiler/src/tokens/token_constants.dart';
21 import 'package:compiler/src/io/source_file.dart'; 21 import 'package:compiler/src/io/source_file.dart';
22 import 'package:compiler/src/string_validator.dart'; 22 import 'package:compiler/src/string_validator.dart';
23 import 'package:compiler/src/tree/tree.dart' show DartString; 23 import 'package:compiler/src/tree/tree.dart' show DartString;
24 import 'package:compiler/src/tree/tree.dart' as tree; 24 import 'package:compiler/src/tree/tree.dart' as tree;
25 import '../options_helper.dart';
25 26
26 /// For debugging the [AstBuilder] stack. Prints information about [x]. 27 /// For debugging the [AstBuilder] stack. Prints information about [x].
27 void show(x) { 28 void show(x) {
28 StringBuffer buf = new StringBuffer(); 29 StringBuffer buf = new StringBuffer();
29 Unparser unparser = new Unparser(buf); 30 Unparser unparser = new Unparser(buf);
30 void unparse(x) { 31 void unparse(x) {
31 if (x is Expression) 32 if (x is Expression)
32 unparser.writeExpression(x); 33 unparser.writeExpression(x);
33 else if (x is TypeAnnotation) 34 else if (x is TypeAnnotation)
34 unparser.writeType(x); 35 unparser.writeType(x);
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 throw new Error(); 667 throw new Error();
667 } 668 }
668 } 669 }
669 } 670 }
670 671
671 Expression parseExpression(String code) { 672 Expression parseExpression(String code) {
672 SourceFile file = new StringSourceFile.fromName('', code); 673 SourceFile file = new StringSourceFile.fromName('', code);
673 Scanner scan = new Scanner(file); 674 Scanner scan = new Scanner(file);
674 Token tok = scan.tokenize(); 675 Token tok = scan.tokenize();
675 AstBuilder builder = new AstBuilder(); 676 AstBuilder builder = new AstBuilder();
676 Parser parser = new Parser(builder); 677 Parser parser = new Parser(builder, new MockParserOptions());
677 tok = parser.parseExpression(tok); 678 tok = parser.parseExpression(tok);
678 if (builder.stack.length != 1 || tok.kind != EOF_TOKEN) { 679 if (builder.stack.length != 1 || tok.kind != EOF_TOKEN) {
679 throw "Parse error in $code"; 680 throw "Parse error in $code";
680 } 681 }
681 return builder.pop(); 682 return builder.pop();
682 } 683 }
683 Statement parseStatement(String code) { 684 Statement parseStatement(String code) {
684 SourceFile file = new StringSourceFile.fromName('', code); 685 SourceFile file = new StringSourceFile.fromName('', code);
685 Scanner scan = new Scanner(file); 686 Scanner scan = new Scanner(file);
686 Token tok = scan.tokenize(); 687 Token tok = scan.tokenize();
687 AstBuilder builder = new AstBuilder(); 688 AstBuilder builder = new AstBuilder();
688 Parser parser = new Parser(builder); 689 Parser parser = new Parser(builder, new MockParserOptions());
689 tok = parser.parseStatement(tok); 690 tok = parser.parseStatement(tok);
690 if (builder.stack.length != 1 || tok.kind != EOF_TOKEN) { 691 if (builder.stack.length != 1 || tok.kind != EOF_TOKEN) {
691 throw "Parse error in $code"; 692 throw "Parse error in $code";
692 } 693 }
693 return builder.pop(); 694 return builder.pop();
694 } 695 }
695 696
696 String unparseExpression(Expression exp) { 697 String unparseExpression(Expression exp) {
697 StringBuffer buf = new StringBuffer(); 698 StringBuffer buf = new StringBuffer();
698 new Unparser(buf).writeExpression(exp); 699 new Unparser(buf).writeExpression(exp);
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 checkStatement("do while(x); while (y);"); 980 checkStatement("do while(x); while (y);");
980 checkStatement("{do; while(x); while (y);}"); 981 checkStatement("{do; while(x); while (y);}");
981 982
982 checkStatement('switch(x) { case 1: case 2: return y; }'); 983 checkStatement('switch(x) { case 1: case 2: return y; }');
983 checkStatement('switch(x) { default: return y; }'); 984 checkStatement('switch(x) { default: return y; }');
984 checkStatement('switch(x) { case 1: x=y; default: return y; }'); 985 checkStatement('switch(x) { case 1: x=y; default: return y; }');
985 checkStatement('switch(x) { case 1: x=y; y=z; break; default: return y; }'); 986 checkStatement('switch(x) { case 1: x=y; y=z; break; default: return y; }');
986 987
987 } 988 }
988 989
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/analyze_helper.dart ('k') | tests/compiler/dart2js/bad_loop_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698