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

Unified Diff: tests/language/modulo_test.dart

Issue 68663003: Merge TRUNCDIV and MOD into TRUNCDIV_MOD single operation. (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 30236)
+++ tests/language/modulo_test.dart (working copy)
@@ -11,23 +11,18 @@
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 ~/ 256 + i % 256, fooTwo(i));
+ Expect.equals(i ~/ -256 + i % -256, booTwo(i));
+ Expect.throws(() => hooTwo(i), (e) => e is IntegerDivisionByZeroException);
}
}
-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;
-
-boo(i) {
- return i % -256;
-}
-
-
-hoo(i) {
- return i % 0;
-}
+fooTwo(i) => i ~/ 256 + i % 256;
+booTwo(i) => i ~/ -256 + i % -256;
+hooTwo(i) => i ~/ 0 + i % 0;
« runtime/vm/intermediate_language_x64.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