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

Side by Side Diff: frog/tests/leg/is_inference_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
« no previous file with comments | « frog/tests/leg/identity_test.dart ('k') | frog/tests/leg/leg.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, 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
5 #import("compiler_helper.dart");
6
7 final String TEST_IF = @"""
8 test(param) {
9 if (param is int) {
10 param = param + 42;
11 }
12 return param + 53;
13 }
14 """;
15
16 final String TEST_IF_ELSE = @"""
17 test(param) {
18 if (param is int) {
19 param = param + 42;
20 } else {
21 param = param + 53;
22 }
23 return param + 53;
24 }
25 """;
26
27 final String TEST_IF_RETURN = @"""
28 test(param) {
29 if (param is int) {
30 return param + 42;
31 }
32 return param + 53;
33 }
34 """;
35
36 final String TEST_IF_NOT_ELSE = @"""
37 test(param) {
38 if (param is !int) {
39 param = param + 53;
40 } else {
41 param = param + 42;
42 }
43 return param;
44 }
45 """;
46
47 final String TEST_IF_NOT_RETURN = @"""
48 test(param) {
49 if (param is !int) return param + 53;
50 return param + 42;
51 }
52 """;
53
54 final String TEST_IF_NOT_ELSE_RETURN = @"""
55 test(param) {
56 if (param is !int) {
57 return param + 53;
58 } else {
59 param = param + 42;
60 }
61 return param;
62 }
63 """;
64
65 compileAndTest(String code) {
66 String generated = compile(code, 'test');
67 print(code);
68 print(generated);
69 RegExp validAdd = new RegExp("$anyIdentifier \\+ 42");
70 RegExp invalidAdd = new RegExp("$anyIdentifier \\+ 53");
71 Expect.isTrue(validAdd.hasMatch(generated));
72 Expect.isFalse(invalidAdd.hasMatch(generated));
73 }
74
75 main() {
76 compileAndTest(TEST_IF);
77 compileAndTest(TEST_IF_ELSE);
78 compileAndTest(TEST_IF_RETURN);
79 compileAndTest(TEST_IF_NOT_ELSE);
80 compileAndTest(TEST_IF_NOT_RETURN);
81 compileAndTest(TEST_IF_NOT_ELSE_RETURN);
82 }
OLDNEW
« no previous file with comments | « frog/tests/leg/identity_test.dart ('k') | frog/tests/leg/leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698