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

Side by Side Diff: frog/tests/leg/src/SsaPhiCodegenTest.dart

Issue 10250002: test rename overhaul: step 5 - frog and leg tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 TEST_ONE = @"""
9 void foo(bar) {
10 var a = 1;
11 if (bar) {
12 a = 2;
13 } else {
14 a = 3;
15 }
16 print(a);
17 }
18 """;
19
20 final String TEST_TWO = @"""
21 void main() {
22 var t = 0;
23 for (var i = 0; i == 0; i = i + 1) {
24 t = t + 10;
25 }
26 print(t);
27 }
28 """;
29
30 final String TEST_THREE = @"""
31 foo(b, c) {
32 var val = 42;
33 if (b) {
34 if (c) {
35 val = 43;
36 }
37 }
38 return val;
39 }
40 """;
41
42 final String TEST_FOUR = @"""
43 foo() {
44 var cond1 = true;
45 var cond2 = false;
46 for (var i = 0; cond1; i = i + 1) {
47 if (i == 9) cond1 = false;
48 for (var j = 0; cond2; j = j + 1) {
49 if (j == 9) cond2 = false;
50 }
51 }
52 print(cond1);
53 print(cond2);
54 }
55 """;
56
57 main() {
58 String generated = compile(TEST_ONE, 'foo');
59 RegExp regexp = const RegExp(@"a = 2");
60 Expect.isTrue(regexp.hasMatch(generated));
61
62 regexp = const RegExp(@"a = 3");
63 Expect.isTrue(regexp.hasMatch(generated));
64
65 regexp = const RegExp(@"print\(a\)");
66 Expect.isTrue(regexp.hasMatch(generated));
67
68 generated = compile(TEST_TWO, 'main');
69 regexp = new RegExp("t = \\(?$anyIdentifier +");
70 Expect.isTrue(regexp.hasMatch(generated));
71
72 // TODO(ngeoffray): Add live range analysis to the codegen
73 // to make this test pass.
74 regexp = new RegExp("i = \\(?$anyIdentifier +");
75 Expect.isFalse(regexp.hasMatch(generated));
76
77 generated = compile(TEST_THREE, 'foo');
78
79 // Check that we don't have 'val = val'.
80 regexp = const RegExp("val = val;");
81 Expect.isTrue(!regexp.hasMatch(generated));
82
83 regexp = const RegExp("return val");
84 Expect.isTrue(regexp.hasMatch(generated));
85 // Check that a store just after the declaration of the local
86 // only generates one instruction.
87 regexp = const RegExp(@"var val = 42");
88 Expect.isTrue(regexp.hasMatch(generated));
89
90 generated = compile(TEST_FOUR, 'foo');
91
92 regexp = const RegExp("cond1 = cond1;");
93 Expect.isTrue(!regexp.hasMatch(generated));
94
95 regexp = const RegExp("cond2 = cond2;");
96 Expect.isTrue(!regexp.hasMatch(generated));
97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698