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

Side by Side Diff: frog/tests/leg/src/TypeInferenceTest.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
5 #import("compiler_helper.dart");
6
7 final String TEST_ONE = @"""
8 sum(param0, param1) {
9 var sum = 0;
10 for (var i = param0; i < param1; i += 1) sum = sum + i;
11 return sum;
12 }
13 """;
14
15 final String TEST_TWO = @"""
16 foo(int param0) {
17 return -param0;
18 }
19 """;
20
21 final String TEST_TWO_WITH_BAILOUT = @"""
22 foo(int param0) {
23 var t;
24 for (int i = 0; i < 1; i++) {
25 t = -param0;
26 }
27 return t;
28 }
29 """;
30
31 final String TEST_THREE = @"""
32 foo(c) {
33 for (int i = 0; i < 10; i++) print(c[i]);
34 }
35 """;
36
37 final String TEST_FOUR = @"""
38 foo(String c) {
39 print(c[0]); // Force a type guard.
40 while (true) print(c.length);
41 }
42 """;
43
44 final String TEST_FIVE = @"""
45 foo(a) {
46 a[0] = 1;
47 print(a[1]);
48 }
49 """;
50
51 final String TEST_FIVE_WITH_BAILOUT = @"""
52 foo(a) {
53 for (int i = 0; i < 1; i++) {
54 a[0] = 1;
55 print(a[1]);
56 }
57 }
58 """;
59
60 final String TEST_SIX = @"""
61 foo(a) {
62 print(a[0]);
63 while (true) {
64 a[0] = a[1];
65 }
66 }
67 """;
68
69 main() {
70 String generated = compile(TEST_ONE, 'sum');
71
72 RegExp regexp = new RegExp("sum = \\(?$anyIdentifier \\+ $anyIdentifier\\)?");
73 Expect.isTrue(regexp.hasMatch(generated));
74
75 regexp = const RegExp("typeof param1 !== 'number'");
76 Expect.isTrue(regexp.hasMatch(generated));
77
78 generated = compile(TEST_TWO, 'foo');
79 regexp = new RegExp(getNumberTypeCheck('param0'));
80 Expect.isTrue(!regexp.hasMatch(generated));
81
82 regexp = const RegExp('-param0');
83 Expect.isTrue(!regexp.hasMatch(generated));
84
85 generated = compile(TEST_TWO_WITH_BAILOUT, 'foo');
86 regexp = new RegExp(getNumberTypeCheck('param0'));
87 Expect.isTrue(regexp.hasMatch(generated));
88
89 regexp = const RegExp('-param0');
90 Expect.isTrue(regexp.hasMatch(generated));
91
92 generated = compile(TEST_THREE, 'foo');
93 regexp = new RegExp("c[$anyIdentifier]");
94 Expect.isTrue(regexp.hasMatch(generated));
95
96 generated = compile(TEST_FOUR, 'foo');
97 regexp = new RegExp("c.length");
98 Expect.isTrue(regexp.hasMatch(generated));
99
100 generated = compile(TEST_FIVE, 'foo');
101 regexp = const RegExp('a.constructor !== Array');
102 Expect.isTrue(!regexp.hasMatch(generated));
103 Expect.isTrue(generated.contains('index'));
104 Expect.isTrue(generated.contains('indexSet'));
105
106 generated = compile(TEST_FIVE_WITH_BAILOUT, 'foo');
107 regexp = const RegExp('a.constructor !== Array');
108 Expect.isTrue(regexp.hasMatch(generated));
109 Expect.isTrue(!generated.contains('index'));
110 Expect.isTrue(!generated.contains('indexSet'));
111
112 generated = compile(TEST_SIX, 'foo');
113 regexp = const RegExp('a.constructor !== Array');
114 Expect.isTrue(regexp.hasMatch(generated));
115 Expect.isTrue(!generated.contains('index'));
116 Expect.isTrue(!generated.contains('indexSet'));
117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698