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

Unified Diff: frog/tests/leg/src/TypeInferenceTest.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « frog/tests/leg/src/TypeGuardUnuserTest.dart ('k') | lib/compiler/implementation/ssa/bailout.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/tests/leg/src/TypeInferenceTest.dart
diff --git a/frog/tests/leg/src/TypeInferenceTest.dart b/frog/tests/leg/src/TypeInferenceTest.dart
index dcae12b341166493829c49755e412f30a566e10f..5d64e89b19df8af6485202b3d83bc0073d0a9dfb 100644
--- a/frog/tests/leg/src/TypeInferenceTest.dart
+++ b/frog/tests/leg/src/TypeInferenceTest.dart
@@ -18,6 +18,16 @@ foo(int param0) {
}
""";
+final String TEST_TWO_WITH_BAILOUT = @"""
+foo(int param0) {
+ var t;
+ for (int i = 0; i < 1; i++) {
+ t = -param0;
+ }
+ return t;
+}
+""";
+
final String TEST_THREE = @"""
foo(c) {
for (int i = 0; i < 10; i++) print(c[i]);
@@ -38,8 +48,17 @@ foo(a) {
}
""";
+final String TEST_FIVE_WITH_BAILOUT = @"""
+foo(a) {
+ for (int i = 0; i < 1; i++) {
+ a[0] = 1;
+ print(a[1]);
+ }
+}
+""";
+
final String TEST_SIX = @"""
-main(a) {
+foo(a) {
print(a[0]);
while (true) {
a[0] = a[1];
@@ -58,6 +77,13 @@ main() {
generated = compile(TEST_TWO, 'foo');
regexp = new RegExp(getNumberTypeCheck('param0'));
+ Expect.isTrue(!regexp.hasMatch(generated));
+
+ regexp = const RegExp('-param0');
+ Expect.isTrue(!regexp.hasMatch(generated));
+
+ generated = compile(TEST_TWO_WITH_BAILOUT, 'foo');
+ regexp = new RegExp(getNumberTypeCheck('param0'));
Expect.isTrue(regexp.hasMatch(generated));
regexp = const RegExp('-param0');
@@ -73,11 +99,17 @@ main() {
generated = compile(TEST_FIVE, 'foo');
regexp = const RegExp('a.constructor !== Array');
+ Expect.isTrue(!regexp.hasMatch(generated));
+ Expect.isTrue(generated.contains('index'));
+ Expect.isTrue(generated.contains('indexSet'));
+
+ generated = compile(TEST_FIVE_WITH_BAILOUT, 'foo');
+ regexp = const RegExp('a.constructor !== Array');
Expect.isTrue(regexp.hasMatch(generated));
Expect.isTrue(!generated.contains('index'));
Expect.isTrue(!generated.contains('indexSet'));
- generated = compile(TEST_FIVE, 'foo');
+ generated = compile(TEST_SIX, 'foo');
regexp = const RegExp('a.constructor !== Array');
Expect.isTrue(regexp.hasMatch(generated));
Expect.isTrue(!generated.contains('index'));
« no previous file with comments | « frog/tests/leg/src/TypeGuardUnuserTest.dart ('k') | lib/compiler/implementation/ssa/bailout.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698