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

Unified Diff: test/mjsunit/nans.js

Issue 422063005: Contribution of PowerPC port. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: re-upload - catch up to 8/19 level Created 6 years, 4 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: test/mjsunit/nans.js
diff --git a/test/mjsunit/nans.js b/test/mjsunit/nans.js
index 987ad6e78ef9ed4682ca3d081db0db8bb0dc43dc..486bc8ca664906bd96ab1bf42d82576ce4a49dda 100644
--- a/test/mjsunit/nans.js
+++ b/test/mjsunit/nans.js
@@ -27,6 +27,11 @@
// Flags: --allow-natives-syntax
+// Helper to determine endian - returns true on little endian platforms
+function isLittleEndian() {
+ return ((new Uint32Array((new Uint8Array([4,3,2,1])).buffer))[0])
+ == 0x01020304;
+}
// Test that both kinds of NaNs (signaling or quiet) do not signal
@@ -41,7 +46,11 @@ function TestAllModes(f) {
function TestDoubleSignalingNan() {
// NaN with signal bit set
function f() {
+ if(isLittleEndian()) {
var bytes = new Uint32Array([1, 0x7FF00000]);
+ } else {
+ var bytes = new Uint32Array([0x7FF00000, 1]);
+ }
var doubles = new Float64Array(bytes.buffer);
assertTrue(isNaN(doubles[0]));
assertTrue(isNaN(doubles[0]*2.0));
@@ -56,7 +65,11 @@ TestDoubleSignalingNan();
function TestDoubleQuietNan() {
// NaN with signal bit cleared
function f() {
+ if(isLittleEndian()) {
var bytes = new Uint32Array([0, 0x7FF80000]);
+ } else {
+ var bytes = new Uint32Array([0x7FF80000, 0]);
+ }
var doubles = new Float64Array(bytes.buffer);
assertTrue(isNaN(doubles[0]));
assertTrue(isNaN(doubles[0]*2.0));

Powered by Google App Engine
This is Rietveld 408576698