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

Unified Diff: tests/language/modulo_test.dart

Issue 79653002: Merge TRUNCDIV and MOD into one instruction. Icorporated feedback from CL https://codereview.chromi… (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/arithmetic_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/modulo_test.dart
===================================================================
--- tests/language/modulo_test.dart (revision 30526)
+++ tests/language/modulo_test.dart (working copy)
@@ -8,26 +8,57 @@
main() {
+ // Prime IC cache.
+ noDom(1);
+ noDom(-1);
for (int i = -30; i < 30; i++) {
Expect.equals(i % 256, foo(i));
Expect.equals(i % -256, boo(i));
- try {
- hoo(i);
- Expect.fail("Exception expected.");
- } catch (e) {}
+ Expect.throws(() => hoo(i), (e) => e is IntegerDivisionByZeroException);
+
+ Expect.equals(i ~/ 254 + i % 254, fooTwo(i));
+ Expect.equals(i ~/ -254 + i % -254, booTwo(i));
+ Expect.throws(() => hooTwo(i), (e) => e is IntegerDivisionByZeroException);
+ if (i > 0) {
+ Expect.equals(i % 10, noDom(i));
+ } else {
+ Expect.equals(i ~/ 10, noDom(i));
+ }
+ Expect.equals((i ~/ 10) + (i ~/ 10) + (i % 10), threeOp(i));
+ Expect.equals((i ~/ 10) + (i ~/ 12) + (i % 10) + (i % 12), fourOp(i));
}
}
-foo(i) {
- return i % 256; // This will get optimized to AND instruction.
-}
+foo(i) => i % 256; // This will get optimized to AND instruction.
+boo(i) => i % -256;
+hoo(i) => i % 0;
+fooTwo(i) => i ~/ 254 + i % 254;
+booTwo(i) => i ~/ -254 + i % -254;
+hooTwo(i) => i ~/ 0 + i % 0;
-boo(i) {
- return i % -256;
+noDom(a) {
+ var x;
+ if (a > 0) {
+ x = a % 10;
+ } else {
+ x = a ~/ 10;
+ }
+ return x;
}
+threeOp(a) {
+ var x = a ~/ 10;
+ var y = a ~/ 10;
+ var z = a % 10;
+ return x + y + z;
+}
-hoo(i) {
- return i % 0;
-}
+
+fourOp(a) {
+ var x0 = a ~/ 10;
+ var x1 = a ~/ 12;
+ var y0 = a % 10;
+ var y1 = a % 12;
+ return x0 + x1 + y0 + y1;
+}
« no previous file with comments | « tests/language/arithmetic_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698