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

Unified Diff: tests/standalone/53bit_overflow_test.dart

Issue 21301003: Fixes javascript integer overflow check. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
Index: tests/standalone/53bit_overflow_test.dart
===================================================================
--- tests/standalone/53bit_overflow_test.dart (revision 25633)
+++ tests/standalone/53bit_overflow_test.dart (working copy)
@@ -29,12 +29,12 @@
int max_add_throws() {
- return 0xFFFFFFFFFFFFF + 1;
+ return 0x1FFFFFFFFFFFFF + 1;
}
int min_sub_throws() {
- return -0xFFFFFFFFFFFFF - 2;
+ return -0x1FFFFFFFFFFFFF - 1;
}
@@ -45,39 +45,39 @@
int max_literal() {
- return 0xFFFFFFFFFFFFF;
+ return 0x1FFFFFFFFFFFFF;
}
int min_literal() {
- var min_literal = -0xFFFFFFFFFFFFF - 1;
+ var min_literal = -0x1FFFFFFFFFFFFF;
return min_literal;
}
-// We don't test for the _FiftyThreeBitOverflowError since it's not visible.
-// It's should not be visible since it doesn't exist on dart2js.
-bool is53BitError(e) => e is Error && "$e".startsWith("53-bit Overflow:");
+// We don't test for the _FiftyFourBitOverflowError since it's not visible.
+// It should not be visible since it doesn't exist on dart2js.
+bool is54BitError(e) => e is Error && "$e".startsWith("54-bit Overflow:");
main() {
- Expect.equals(0xFFFFFFFFFFFFF, max_literal());
- Expect.equals(-0xFFFFFFFFFFFFF - 1, min_literal());
+ Expect.equals(0x1FFFFFFFFFFFFF, max_literal());
+ Expect.equals(-0x1FFFFFFFFFFFFF, min_literal());
// Run the tests once before optimizations.
dti_arg = 1.9e16;
- Expect.throws(double_to_int, is53BitError);
+ Expect.throws(double_to_int, is54BitError);
- ia_arg1 = (1 << 51);
- ia_arg2 = (1 << 51);
- Expect.throws(integer_add, is53BitError);
+ ia_arg1 = (1 << 52);
+ ia_arg2 = (1 << 52);
+ Expect.throws(integer_add, is54BitError);
- n_arg = -0xFFFFFFFFFFFFF - 1;
- Expect.throws(negate, is53BitError);
+ n_arg = -0x1FFFFFFFFFFFFF;
+ Expect.equals(0x1FFFFFFFFFFFFF, negate());
- is_arg = (1 << 51);
- Expect.throws(integer_shift, is53BitError);
+ is_arg = (1 << 52);
+ Expect.throws(integer_shift, is54BitError);
- Expect.throws(max_add_throws, is53BitError);
- Expect.throws(min_sub_throws, is53BitError);
+ Expect.throws(max_add_throws, is54BitError);
+ Expect.throws(min_sub_throws, is54BitError);
for (int i = 0; i < 20; i++) {
dti_arg = i.toDouble();
@@ -101,18 +101,18 @@
// The optimized functions should now deoptimize and throw the error.
dti_arg = 1.9e16;
- Expect.throws(double_to_int, is53BitError);
+ Expect.throws(double_to_int, is54BitError);
- ia_arg1 = (1 << 51);
- ia_arg2 = (1 << 51);
- Expect.throws(integer_add, is53BitError);
+ ia_arg1 = (1 << 52);
+ ia_arg2 = (1 << 52);
+ Expect.throws(integer_add, is54BitError);
- n_arg = -0xFFFFFFFFFFFFF - 1;
- Expect.throws(negate, is53BitError);
+ n_arg = -0x1FFFFFFFFFFFFF;
+ Expect.equals(0x1FFFFFFFFFFFFF, negate());
- is_arg = (1 << 51);
- Expect.throws(integer_shift, is53BitError);
+ is_arg = (1 << 52);
+ Expect.throws(integer_shift, is54BitError);
- Expect.throws(max_add_throws, is53BitError);
- Expect.throws(min_sub_throws, is53BitError);
+ Expect.throws(max_add_throws, is54BitError);
+ Expect.throws(min_sub_throws, is54BitError);
}

Powered by Google App Engine
This is Rietveld 408576698