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

Side by Side Diff: frog/tests/leg/src/TypeGuardUnuserTest.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 foo(a) {
9 int c = foo(1);
10 if (a) c = foo(2);
11 return c;
12 }
13 """;
14
15
16 final String TEST_TWO = @"""
17 bar(a) {}
18 foo(d) {
19 int a = 1;
20 int c = foo(1);
21 if (true) {}
22 return a + c;
23 }
24 """;
25
26 final String TEST_THREE = @"""
27 foo(int param1, int param2) {
28 return 0 + param1 + param2;
29 }
30 """;
31
32 final String TEST_THREE_WITH_BAILOUT = @"""
33 foo(int param1, int param2) {
34 var t;
35 for (int i = 0; i < 1; i++) {
36 t = 0 + param1 + param2;
37 }
38 return t;
39 }
40 """;
41
42 main() {
43 String generated = compile(TEST_ONE, 'foo');
44 RegExp regexp = new RegExp(getIntTypeCheck(anyIdentifier));
45 Iterator<Match> matches = regexp.allMatches(generated).iterator();
46 checkNumberOfMatches(matches, 0);
47
48 regexp = const RegExp("return c;");
49 Expect.isTrue(regexp.hasMatch(generated));
50
51 generated = compile(TEST_TWO, 'foo');
52 regexp = const RegExp("foo\\(1\\)");
53 matches = regexp.allMatches(generated).iterator();
54 checkNumberOfMatches(matches, 1);
55
56 generated = compile(TEST_THREE, 'foo');
57 regexp = new RegExp(getNumberTypeCheck('param1'));
58 Expect.isTrue(!regexp.hasMatch(generated));
59 regexp = new RegExp(getNumberTypeCheck('param2'));
60 Expect.isTrue(!regexp.hasMatch(generated));
61
62 generated = compile(TEST_THREE_WITH_BAILOUT, 'foo');
63 regexp = new RegExp(getNumberTypeCheck('param1'));
64 Expect.isTrue(regexp.hasMatch(generated));
65 regexp = new RegExp(getNumberTypeCheck('param2'));
66 Expect.isTrue(regexp.hasMatch(generated));
67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698