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

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

Issue 900403003: Support default constructors in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 /// Unittest test of the CPS ir generated by the dart2dart compiler. 5 /// Unittest test of the CPS ir generated by the dart2dart compiler.
6 library dart_backend.sexpr2_test; 6 library dart_backend.sexpr2_test;
7 7
8 import 'package:compiler/src/dart2jslib.dart'; 8 import 'package:compiler/src/dart2jslib.dart';
9 import 'package:compiler/src/cps_ir/cps_ir_nodes.dart';
9 import 'package:compiler/src/cps_ir/cps_ir_nodes_sexpr.dart'; 10 import 'package:compiler/src/cps_ir/cps_ir_nodes_sexpr.dart';
10 import 'package:compiler/src/elements/elements.dart'; 11 import 'package:compiler/src/elements/elements.dart';
11 import 'package:expect/expect.dart'; 12 import 'package:expect/expect.dart';
12 13
13 import '../../../../pkg/analyzer2dart/test/test_helper.dart'; 14 import '../../../../pkg/analyzer2dart/test/test_helper.dart';
14 import '../../../../pkg/analyzer2dart/test/sexpr_data.dart'; 15 import '../../../../pkg/analyzer2dart/test/sexpr_data.dart';
15 16
16 import 'test_helper.dart'; 17 import 'test_helper.dart';
17 18
18 main() { 19 main(List<String> args) {
19 performTests(TEST_DATA, asyncTester, (TestSpec result) { 20 performTests(TEST_DATA, asyncTester, runTest, args);
20 return compilerFor(result.input).then((Compiler compiler) { 21 }
21 void checkOutput(String elementName, 22
22 Element element, 23 runTest(TestSpec result) {
23 String expectedOutput) { 24 return compilerFor(result.input).then((Compiler compiler) {
25 void checkOutput(String elementName,
26 Element element,
27 String expectedOutput) {
28 ExecutableDefinition ir = compiler.irBuilder.getIr(element);
29 if (expectedOutput == null) {
30 Expect.isNull(ir, "\nInput:\n${result.input}\n"
31 "No CPS IR expected for $element");
32 } else {
33 Expect.isNotNull(ir, "\nInput:\n${result.input}\n"
34 "No CPS IR for $element");
24 expectedOutput = expectedOutput.trim(); 35 expectedOutput = expectedOutput.trim();
25 String output = compiler.irBuilder.getIr(element) 36 String output = ir.accept(new SExpressionStringifier()).trim();
26 .accept(new SExpressionStringifier()).trim();
27 Expect.equals(expectedOutput, output, 37 Expect.equals(expectedOutput, output,
28 "\nInput:\n${result.input}\n" 38 "\nInput:\n${result.input}\n"
29 "Expected for '$elementName':\n$expectedOutput\n" 39 "Expected for '$elementName':\n$expectedOutput\n"
30 "Actual for '$elementName':\n$output\n"); 40 "Actual for '$elementName':\n$output\n");
31 } 41 }
42 }
32 43
33 if (result.output is String) { 44 if (result.output is String) {
34 checkOutput('main', compiler.mainFunction, result.output); 45 checkOutput('main', compiler.mainFunction, result.output);
35 } else { 46 } else {
36 assert(result.output is Map<String, String>); 47 assert(result.output is Map<String, String>);
37 result.output.forEach((String elementName, String output) { 48 result.output.forEach((String elementName, String output) {
38 Element element; 49 Element element;
39 if (elementName.contains('.')) { 50 if (elementName.contains('.')) {
40 ClassElement cls = compiler.mainApp.localLookup( 51 ClassElement cls = compiler.mainApp.localLookup(
41 elementName.substring(0, elementName.indexOf('.'))); 52 elementName.substring(0, elementName.indexOf('.')));
42 element = cls.localLookup( 53 element = cls.localLookup(
43 elementName.substring(elementName.indexOf('.') + 1)); 54 elementName.substring(elementName.indexOf('.') + 1));
44 } else { 55 } else {
45 element = compiler.mainApp.localLookup(elementName); 56 element = compiler.mainApp.localLookup(elementName);
46 } 57 }
47 checkOutput(elementName, element, output); 58 checkOutput(elementName, element, output);
48 }); 59 });
49 } 60 }
50 });
51 }); 61 });
52 } 62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698