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

Unified Diff: test/mjsunit/nans.js

Issue 13470002: Test behavior of qNaN and sNaN (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments Created 7 years, 9 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 | « src/ia32/code-stubs-ia32.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/nans.js
diff --git a/test/mjsunit/compiler/property-static.js b/test/mjsunit/nans.js
similarity index 52%
copy from test/mjsunit/compiler/property-static.js
copy to test/mjsunit/nans.js
index 07021340cd7aa94440638f925eeed921ee78c9c7..d212afdeeda250d550bd10462f5a87a9b2e8f663 100644
--- a/test/mjsunit/compiler/property-static.js
+++ b/test/mjsunit/nans.js
@@ -27,43 +27,77 @@
// Flags: --allow-natives-syntax
-// Test usage of static type information for loads that would otherwise
-// turn into polymorphic or generic loads.
-
-// Prepare a highly polymorphic load to be used by all tests.
-Object.prototype.load = function() { return this.property; };
-Object.prototype.load.call({ A:0, property:10 });
-Object.prototype.load.call({ A:0, B:0, property:11 });
-Object.prototype.load.call({ A:0, B:0, C:0, property:12 });
-Object.prototype.load.call({ A:0, B:0, C:0, D:0, property:13 });
-Object.prototype.load.call({ A:0, B:0, C:0, D:0, E:0, property:14 });
-Object.prototype.load.call({ A:0, B:0, C:0, D:0, E:0, F:0, property:15 });
-
-// Test for object literals.
-(function() {
- function f(x) {
- var object = { property:x };
- return object.load();
- }
- assertSame(1, f(1));
- assertSame(2, f(2));
+// Test that both kinds of NaNs (signaling or quiet) do not signal
+
+function TestAllModes(f) {
+ f(); // Runtime
+ f(); // IC
+ f(); // IC second time
%OptimizeFunctionOnNextCall(f);
- assertSame(3, f(3));
-})();
+ f(); // hydrogen
+}
+
+function TestDoubleSignalingNan() {
+ // NaN with signal bit set
+ function f() {
+ var bytes = new Uint32Array([1, 0x7FF00000]);
+ var doubles = new Float64Array(bytes.buffer);
+ assertTrue(isNaN(doubles[0]));
+ assertTrue(isNaN(doubles[0]*2.0));
+ assertTrue(isNaN(doubles[0] + 0.5));
+ }
+
+ TestAllModes(f);
+}
-// Test for inlined constructors.
-(function() {
- function c(x) {
- this.property = x;
+TestDoubleSignalingNan();
+
+function TestDoubleQuietNan() {
+ // NaN with signal bit cleared
+ function f() {
+ var bytes = new Uint32Array([0, 0x7FF80000]);
+ var doubles = new Float64Array(bytes.buffer);
+ assertTrue(isNaN(doubles[0]));
+ assertTrue(isNaN(doubles[0]*2.0));
+ assertTrue(isNaN(doubles[0] + 0.5));
}
- function f(x) {
- var object = new c(x);
- return object.load();
+
+ TestAllModes(f);
+}
+
+TestDoubleQuietNan();
+
+function TestFloatSignalingNan() {
+ // NaN with signal bit set
+ function f() {
+ var bytes = new Uint32Array([0x7F800001]);
+ var floats = new Float32Array(bytes.buffer);
+ assertTrue(isNaN(floats[0]));
+ assertTrue(isNaN(floats[0]*2.0));
+ assertTrue(isNaN(floats[0] + 0.5));
}
- assertSame(1, f(1));
- assertSame(2, f(2));
- %OptimizeFunctionOnNextCall(f);
- assertSame(3, f(3));
-})();
+ TestAllModes(f);
+}
+
+TestFloatSignalingNan();
+
+function TestFloatQuietNan() {
+ // NaN with signal bit cleared
+ function f() {
+ var bytes = new Uint32Array([0x7FC00000]);
+ var floats = new Float32Array(bytes.buffer);
+ assertTrue(isNaN(floats[0]));
+ assertTrue(isNaN(floats[0]*2.0));
+ assertTrue(isNaN(floats[0] + 0.5));
+ }
+
+ TestAllModes(f);
+}
+
+TestFloatQuietNan();
+
+
+
+
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698