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

Unified Diff: tests/language/truncdiv_test.dart

Issue 81623003: Use range information to omit checks in TRUNCDIV/MOD operations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 | « tests/language/modulo_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/truncdiv_test.dart
===================================================================
--- tests/language/truncdiv_test.dart (revision 0)
+++ tests/language/truncdiv_test.dart (working copy)
@@ -0,0 +1,35 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Dart test optimization of modulo operator on Smi.
+// VMOptions=--optimization-counter-threshold=10 --no-use-osr
+
+import "package:expect/expect.dart";
+
+
+main() {
+ for (int i = -30; i < 30; i++) {
+ Expect.equals(i % 9, foo(i, 9));
+ // Zero test is done outside the loop.
+ if (i < 0) {
+ Expect.equals(i ~/ -i, foo2(i));
+ } else if (i > 0) {
+ Expect.equals(i ~/ i, foo2(i));
+ }
+ }
+ Expect.throws(() => foo(12, 0), (e) => e is IntegerDivisionByZeroException);
+ Expect.throws(() => foo2(0), (e) => e is IntegerDivisionByZeroException);
+}
+
+foo(i, x) => i % x;
+
+foo2(i) {
+ // Make sure x has a range computed.
+ var x = 0;
+ if (i < 0) {
+ x = -i;
+ } else {
+ x = i;
+ }
+ return i ~/ x;
+}
« no previous file with comments | « tests/language/modulo_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698