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

Unified Diff: tests/compiler/dart2js/value_range_test.dart

Issue 23669006: Re-apply: "Fix http://code.google.com/p/dart/issues/detail?id=13007 by introducing a new Marker valu (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 | « sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/value_range_test.dart
===================================================================
--- tests/compiler/dart2js/value_range_test.dart (revision 27277)
+++ tests/compiler/dart2js/value_range_test.dart (working copy)
@@ -11,6 +11,7 @@
const int KEPT = 3;
const int ONE_CHECK = 4;
const int ONE_ZERO_CHECK = 5;
+const int BELOW_ZERO_CHECK = 6;
final List TESTS = [
"""
@@ -197,6 +198,65 @@
}
""",
REMOVED,
+"""
+main(value) {
+ var a = new List(4);
+ var sum = 0;
+ for (int i = 0; i < a.length; i++) {
+ sum += a[i];
+ if (sum == 0) i++;
+ }
+ return sum;
+}
+""",
+REMOVED,
+"""
+main(value) {
+ var a = new List(5);
+ var sum = 0;
+ for (int i = a.length - 1; i >= 0; i--) {
+ sum += a[i];
+ if (sum == 0) i--;
+ }
+ return sum;
+}
+""",
+REMOVED,
+"""
+main(value) {
+ var a = new List(6);
+ var sum = 0;
+ for (int i = 0; i < a.length; i++) {
+ sum += a[i];
+ if (sum == 0) i--;
+ }
+ return sum;
+}
+""",
+BELOW_ZERO_CHECK,
+"""
+main(value) {
+ var a = new List(7);
+ var sum = 0;
+ for (int i = 0; i < a.length;) {
+ sum += a[i];
+ sum == 0 ? i-- : i++;
+ }
+ return sum;
+}
+""",
+BELOW_ZERO_CHECK,
+"""
+main(value) {
+ var a = new List(7);
+ var sum = 0;
+ for (int i = -2; i < a.length; i = 0) {
+ sum += a[i];
+ }
+ return sum;
+}
+""",
+BELOW_ZERO_CHECK,
];
// TODO(ahe): It would probably be better if this test used the real
@@ -290,6 +350,11 @@
case ABOVE_ZERO:
Expect.isTrue(!generated.contains('< 0'));
Expect.isTrue(generated.contains('ioore'));
+ break;
+
+ case BELOW_ZERO_CHECK:
+ Expect.isTrue(generated.contains('< 0'));
+ Expect.isTrue(!generated.contains('||'));
Expect.isTrue(generated.contains('ioore'));
break;
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698