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

Side by Side Diff: frog/tests/leg/pretty_parameter_test.dart

Issue 10536169: Move frog/tests/{leg,leg_only,frog_native} to tests/compiler/. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
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.
4 // Test that parameters keep their names in the output.
5
6 #import("compiler_helper.dart");
7
8 final String FOO = @"""
9 void foo(var a, var b) {
10 }
11 """;
12
13
14 final String BAR = @"""
15 void bar(var eval, var $eval) {
16 }
17 """;
18
19
20 final String PARAMETER_AND_TEMP = @"""
21 void bar(var t0, var b) {
22 {
23 var t0 = 2;
24 if (b) {
25 t0 = 4;
26 } else {
27 t0 = 3;
28 }
29 print(t0);
30 }
31 print(t0);
32 }
33 """;
34
35 final String NO_LOCAL = @"""
36 foo(bar, baz) {
37 if (bar) {
38 baz = 2;
39 } else {
40 baz = 3;
41 }
42 return baz;
43 }
44 """;
45
46 final String MULTIPLE_PHIS_ONE_LOCAL = @"""
47 foo(param1, param2, param3) {
48 var a = 2;
49 if (param1) {
50 if (param2) {
51 if (param3) {
52 a = 42;
53 }
54 }
55 }
56 return a;
57 }
58 """;
59
60 final String PARAMETER_INIT = @"""
61 int foo(var start, bool test) {
62 var result = start;
63 if (test) {
64 result = 42;
65 }
66 return result;
67 }
68 """;
69
70 main() {
71 String generated = compile(FOO, 'foo');
72 // TODO(ngeoffray): Use 'contains' when frog supports it.
73 RegExp regexp = const RegExp(@"function\(a, b\) {");
74 Expect.isTrue(regexp.hasMatch(generated));
75
76 generated = compile(BAR, 'bar');
77 regexp = const RegExp(@"function\(eval\$, \$\$eval\) {");
78 Expect.isTrue(regexp.hasMatch(generated));
79
80 generated = compile(PARAMETER_AND_TEMP, 'bar');
81 regexp = const RegExp(@"print\(t0\)");
82 Expect.isTrue(regexp.hasMatch(generated));
83 // Check that the second 't0' got another name.
84 regexp = const RegExp(@"print\(t0_0\)");
85 Expect.isTrue(regexp.hasMatch(generated));
86
87 generated = compile(NO_LOCAL, 'foo');
88 regexp = const RegExp("return baz");
89 Expect.isTrue(regexp.hasMatch(generated));
90 regexp = const RegExp(@"baz = 2");
91 Expect.isTrue(regexp.hasMatch(generated));
92 regexp = const RegExp(@"baz = 3");
93 Expect.isTrue(regexp.hasMatch(generated));
94 regexp = const RegExp("bar === true");
95 Expect.isTrue(regexp.hasMatch(generated));
96
97 generated = compile(MULTIPLE_PHIS_ONE_LOCAL, 'foo');
98 regexp = const RegExp(@"var a = 2;");
99 Expect.isTrue(regexp.hasMatch(generated));
100
101 regexp = const RegExp(@"a = 2;");
102 Iterator matches = regexp.allMatches(generated).iterator();
103 Expect.isTrue(matches.hasNext());
104 matches.next();
105 Expect.isFalse(matches.hasNext());
106
107 generated = compile(PARAMETER_INIT, 'foo');
108 regexp = const RegExp("var result = start;");
109 Expect.isTrue(regexp.hasMatch(generated));
110 }
OLDNEW
« no previous file with comments | « frog/tests/leg/partial_parser_test.dart ('k') | frog/tests/leg/redundant_phi_eliminator_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698