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

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

Issue 10171007: Reapply "Only emit typeguards if we think they are valuable." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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/src/GVNTest.dart ('k') | frog/tests/leg/src/TypeInferenceTest.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #import("compiler_helper.dart"); 5 #import("compiler_helper.dart");
6 6
7 final String TEST_ONE = @""" 7 final String TEST_ONE = @"""
8 foo(a) { 8 foo(a) {
9 int c = foo(1); 9 int c = foo(1);
10 if (a) c = foo(2); 10 if (a) c = foo(2);
(...skipping 11 matching lines...) Expand all
22 return a + c; 22 return a + c;
23 } 23 }
24 """; 24 """;
25 25
26 final String TEST_THREE = @""" 26 final String TEST_THREE = @"""
27 foo(int param1, int param2) { 27 foo(int param1, int param2) {
28 return 0 + param1 + param2; 28 return 0 + param1 + param2;
29 } 29 }
30 """; 30 """;
31 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 """;
32 41
33 main() { 42 main() {
34 String generated = compile(TEST_ONE, 'foo'); 43 String generated = compile(TEST_ONE, 'foo');
35 RegExp regexp = new RegExp(getIntTypeCheck(anyIdentifier)); 44 RegExp regexp = new RegExp(getIntTypeCheck(anyIdentifier));
36 Iterator<Match> matches = regexp.allMatches(generated).iterator(); 45 Iterator<Match> matches = regexp.allMatches(generated).iterator();
37 checkNumberOfMatches(matches, 0); 46 checkNumberOfMatches(matches, 0);
38 47
39 regexp = const RegExp("return c;"); 48 regexp = const RegExp("return c;");
40 Expect.isTrue(regexp.hasMatch(generated)); 49 Expect.isTrue(regexp.hasMatch(generated));
41 50
42 generated = compile(TEST_TWO, 'foo'); 51 generated = compile(TEST_TWO, 'foo');
43 regexp = const RegExp("foo\\(1\\)"); 52 regexp = const RegExp("foo\\(1\\)");
44 matches = regexp.allMatches(generated).iterator(); 53 matches = regexp.allMatches(generated).iterator();
45 checkNumberOfMatches(matches, 1); 54 checkNumberOfMatches(matches, 1);
46 55
47 generated = compile(TEST_THREE, 'foo'); 56 generated = compile(TEST_THREE, 'foo');
48 regexp = new RegExp(getNumberTypeCheck('param1')); 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'));
49 Expect.isTrue(regexp.hasMatch(generated)); 64 Expect.isTrue(regexp.hasMatch(generated));
50 regexp = new RegExp(getNumberTypeCheck('param2')); 65 regexp = new RegExp(getNumberTypeCheck('param2'));
51 Expect.isTrue(regexp.hasMatch(generated)); 66 Expect.isTrue(regexp.hasMatch(generated));
52 } 67 }
OLDNEW
« no previous file with comments | « frog/tests/leg/src/GVNTest.dart ('k') | frog/tests/leg/src/TypeInferenceTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698