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

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
Index: tests/language/modulo_test.dart
===================================================================
--- tests/language/modulo_test.dart (revision 30485)
+++ tests/language/modulo_test.dart (working copy)
@@ -8,26 +8,39 @@
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));
+ }
}
}
-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;
-}
-
-
-hoo(i) {
- return i % 0;
-}
+noDom(a) {
+ var x;
+ if (a > 0) {
+ x = a % 10;
+ } else {
+ x = a ~/ 10;
+ }
+ return x;
+}
« runtime/vm/intermediate_language_arm.cc ('K') | « tests/language/arithmetic_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698