| 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 "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import 'package:compiler/implementation/constants/values.dart'; | 8 import 'package:compiler/implementation/constants/values.dart'; |
| 9 import 'package:compiler/implementation/dart_backend/backend_ast_nodes.dart'; | 9 import 'package:compiler/implementation/dart_backend/backend_ast_nodes.dart'; |
| 10 import 'package:compiler/implementation/scanner/scannerlib.dart'; | 10 import 'package:compiler/implementation/scanner/scannerlib.dart'; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 var part = parts[i]; | 184 var part = parts[i]; |
| 185 if (part is Expression) { | 185 if (part is Expression) { |
| 186 members.add(part); | 186 members.add(part); |
| 187 } else { | 187 } else { |
| 188 assert(part is Token); | 188 assert(part is Token); |
| 189 DartString str = stringValidator.validateInterpolationPart( | 189 DartString str = stringValidator.validateInterpolationPart( |
| 190 part as Token, | 190 part as Token, |
| 191 quoting, | 191 quoting, |
| 192 isFirst: i == 0, | 192 isFirst: i == 0, |
| 193 isLast: i == parts.length - 1); | 193 isLast: i == parts.length - 1); |
| 194 members.add(new Literal(new StringConstant(str))); | 194 members.add(new Literal(new StringConstantValue(str))); |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 push(new StringConcat(members)); | 197 push(new StringConcat(members)); |
| 198 } | 198 } |
| 199 handleStringJuxtaposition(int litCount) { | 199 handleStringJuxtaposition(int litCount) { |
| 200 push(new StringConcat(popList(litCount, <Expression>[]))); | 200 push(new StringConcat(popList(litCount, <Expression>[]))); |
| 201 } | 201 } |
| 202 endArguments(int count, begin, end) { | 202 endArguments(int count, begin, end) { |
| 203 push(popList(count, <Argument>[])); | 203 push(popList(count, <Argument>[])); |
| 204 } | 204 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 push(r); | 281 push(r); |
| 282 } | 282 } |
| 283 } | 283 } |
| 284 handleAsOperator(operathor, endToken) { | 284 handleAsOperator(operathor, endToken) { |
| 285 TypeAnnotation type = popTypeAnnotation(); | 285 TypeAnnotation type = popTypeAnnotation(); |
| 286 Expression exp = pop(); | 286 Expression exp = pop(); |
| 287 push(new TypeOperator(exp, 'as', type)); | 287 push(new TypeOperator(exp, 'as', type)); |
| 288 } | 288 } |
| 289 handleLiteralBool(Token t) { | 289 handleLiteralBool(Token t) { |
| 290 bool value = t.value == 'true'; | 290 bool value = t.value == 'true'; |
| 291 push(new Literal(value ? new TrueConstant() : new FalseConstant())); | 291 push(new Literal( |
| 292 value ? new TrueConstantValue() : new FalseConstantValue())); |
| 292 } | 293 } |
| 293 handleLiteralDouble(t) { | 294 handleLiteralDouble(t) { |
| 294 push(new Literal(new DoubleConstant(double.parse(t.value)))); | 295 push(new Literal(new DoubleConstantValue(double.parse(t.value)))); |
| 295 } | 296 } |
| 296 handleLiteralInt(Token t) { | 297 handleLiteralInt(Token t) { |
| 297 push(new Literal(new IntConstant(int.parse(t.value)))); | 298 push(new Literal(new IntConstantValue(int.parse(t.value)))); |
| 298 } | 299 } |
| 299 handleLiteralNull(t) { | 300 handleLiteralNull(t) { |
| 300 push(new Literal(new NullConstant())); | 301 push(new Literal(new NullConstantValue())); |
| 301 } | 302 } |
| 302 endLiteralSymbol(Token hash, int idCount) { | 303 endLiteralSymbol(Token hash, int idCount) { |
| 303 List<Identifier> ids = popList(idCount, <Identifier>[]); | 304 List<Identifier> ids = popList(idCount, <Identifier>[]); |
| 304 push(new LiteralSymbol(ids.map((id) => id.name).join('.'))); | 305 push(new LiteralSymbol(ids.map((id) => id.name).join('.'))); |
| 305 } | 306 } |
| 306 handleLiteralList(int count, begin, constKeyword, end) { | 307 handleLiteralList(int count, begin, constKeyword, end) { |
| 307 List<Expression> exps = popList(count, <Expression>[]); | 308 List<Expression> exps = popList(count, <Expression>[]); |
| 308 List<TypeAnnotation> types = pop(); | 309 List<TypeAnnotation> types = pop(); |
| 309 assert(types.length <= 1); | 310 assert(types.length <= 1); |
| 310 push(new LiteralList(exps, | 311 push(new LiteralList(exps, |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 continue; // do not check things from Object, such as hashCode | 633 continue; // do not check things from Object, such as hashCode |
| 633 } | 634 } |
| 634 MethodMirror mm = xm.type.instanceMembers[name]; | 635 MethodMirror mm = xm.type.instanceMembers[name]; |
| 635 if (mm.isGetter) { | 636 if (mm.isGetter) { |
| 636 var xv = xm.getField(name).reflectee; | 637 var xv = xm.getField(name).reflectee; |
| 637 var yv = ym.getField(name).reflectee; | 638 var yv = ym.getField(name).reflectee; |
| 638 checkDeepEqual(xv,yv); | 639 checkDeepEqual(xv,yv); |
| 639 } | 640 } |
| 640 } | 641 } |
| 641 } | 642 } |
| 642 else if (x is PrimitiveConstant && y is PrimitiveConstant) { | 643 else if (x is PrimitiveConstantValue && y is PrimitiveConstantValue) { |
| 643 checkDeepEqual(x.value, y.value); | 644 checkDeepEqual(x.primitiveValue, y.primitiveValue); |
| 644 } | 645 } |
| 645 else if (x is DartString && y is DartString) { | 646 else if (x is DartString && y is DartString) { |
| 646 if (x.slowToString() != y.slowToString()) { | 647 if (x.slowToString() != y.slowToString()) { |
| 647 throw new Error(); | 648 throw new Error(); |
| 648 } | 649 } |
| 649 } | 650 } |
| 650 else { | 651 else { |
| 651 if (x != y) { | 652 if (x != y) { |
| 652 throw new Error(); | 653 throw new Error(); |
| 653 } | 654 } |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 checkStatement("do while(x); while (y);"); | 966 checkStatement("do while(x); while (y);"); |
| 966 checkStatement("{do; while(x); while (y);}"); | 967 checkStatement("{do; while(x); while (y);}"); |
| 967 | 968 |
| 968 checkStatement('switch(x) { case 1: case 2: return y; }'); | 969 checkStatement('switch(x) { case 1: case 2: return y; }'); |
| 969 checkStatement('switch(x) { default: return y; }'); | 970 checkStatement('switch(x) { default: return y; }'); |
| 970 checkStatement('switch(x) { case 1: x=y; default: return y; }'); | 971 checkStatement('switch(x) { case 1: x=y; default: return y; }'); |
| 971 checkStatement('switch(x) { case 1: x=y; y=z; break; default: return y; }'); | 972 checkStatement('switch(x) { case 1: x=y; y=z; break; default: return y; }'); |
| 972 | 973 |
| 973 } | 974 } |
| 974 | 975 |
| OLD | NEW |