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

Unified Diff: test/webkit/mod-crash.js

Issue 18068003: Migrated several tests from blink to V8 repository. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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
« no previous file with comments | « test/webkit/mod-by-zero-expected.txt ('k') | test/webkit/mod-crash-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/webkit/mod-crash.js
diff --git a/test/webkit/concat-while-having-a-bad-time.js b/test/webkit/mod-crash.js
similarity index 65%
copy from test/webkit/concat-while-having-a-bad-time.js
copy to test/webkit/mod-crash.js
index dfda1e08a0b36194b787a44ee12a9693acd8aeaf..2bc01a122c4aa758c5dc2bdf731f7e1b2926125b 100644
--- a/test/webkit/concat-while-having-a-bad-time.js
+++ b/test/webkit/mod-crash.js
@@ -22,10 +22,41 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description(
-"Tests the behavior of Array.prototype.concat while the array is having a bad time due to one of the elements we are concatenating."
+"This test checks that n % 0 doesn't crash with a floating-point exception."
);
-Object.defineProperty(Array.prototype, 0, { writable: false });
-shouldBe("[42].concat()", "[42]");
+shouldBe("2 % 0", "NaN");
+var n = 2;
+shouldBe("n % 0", "NaN");
+function f()
+{
+ return 2 % 0;
+}
+
+shouldBe("f()", "NaN");
+
+function g()
+{
+ var n = 2;
+ return n % 0;
+}
+
+shouldBe("g()", "NaN");
+
+// Test that reusing a floating point value after use in a modulus works correctly.
+function nonSpeculativeModReuseInner(argument, o1, o2)
+{
+ // The + operator on objects is a reliable way to avoid the speculative JIT path for now at least.
+ o1 + o2;
+
+ var knownDouble = argument - 0;
+ return knownDouble % 1 + knownDouble;
+}
+function nonSpeculativeModReuse(argument)
+{
+ return nonSpeculativeModReuseInner(argument, {}, {});
+}
+
+shouldBe("nonSpeculativeModReuse(0.5)", "1");
« no previous file with comments | « test/webkit/mod-by-zero-expected.txt ('k') | test/webkit/mod-crash-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698