OLD | NEW |
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'; |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 push(null); | 580 push(null); |
581 } | 581 } |
582 | 582 |
583 endForIn(Token await, Token begin, Token inKeyword, Token end) { | 583 endForIn(Token await, Token begin, Token inKeyword, Token end) { |
584 Statement body = pop(); | 584 Statement body = pop(); |
585 Expression exp = pop(); | 585 Expression exp = pop(); |
586 Node declaredIdentifier = pop(); | 586 Node declaredIdentifier = pop(); |
587 push(new ForIn(declaredIdentifier, exp, body)); | 587 push(new ForIn(declaredIdentifier, exp, body)); |
588 } | 588 } |
589 | 589 |
590 handleAssertStatement(Token assertKeyword, | 590 handleAssertStatement(Token assertKeyword, Token semicolonToken) { |
591 Token commaToken, Token semicolonToken) { | |
592 Expression message; | |
593 if (commaToken != null) message = pop(); | |
594 Expression exp = pop(); | 591 Expression exp = pop(); |
595 var arguments = [exp]; | 592 Expression call = new CallFunction(new Identifier("assert"), [exp]); |
596 if (message != null) arguments.add(message); | |
597 Expression call = new CallFunction(new Identifier("assert"), arguments); | |
598 push(new ExpressionStatement(call)); | 593 push(new ExpressionStatement(call)); |
599 } | 594 } |
600 | 595 |
601 endLabeledStatement(int labelCount) { | 596 endLabeledStatement(int labelCount) { |
602 Statement statement = pop(); | 597 Statement statement = pop(); |
603 for (int i=0; i<labelCount; i++) { | 598 for (int i=0; i<labelCount; i++) { |
604 String label = pop(asName); | 599 String label = pop(asName); |
605 statement = new LabeledStatement(label, statement); | 600 statement = new LabeledStatement(label, statement); |
606 } | 601 } |
607 push(statement); | 602 push(statement); |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 checkStatement("do while(x); while (y);"); | 974 checkStatement("do while(x); while (y);"); |
980 checkStatement("{do; while(x); while (y);}"); | 975 checkStatement("{do; while(x); while (y);}"); |
981 | 976 |
982 checkStatement('switch(x) { case 1: case 2: return y; }'); | 977 checkStatement('switch(x) { case 1: case 2: return y; }'); |
983 checkStatement('switch(x) { default: return y; }'); | 978 checkStatement('switch(x) { default: return y; }'); |
984 checkStatement('switch(x) { case 1: x=y; default: return y; }'); | 979 checkStatement('switch(x) { case 1: x=y; default: return y; }'); |
985 checkStatement('switch(x) { case 1: x=y; y=z; break; default: return y; }'); | 980 checkStatement('switch(x) { case 1: x=y; y=z; break; default: return y; }'); |
986 | 981 |
987 } | 982 } |
988 | 983 |
OLD | NEW |