Revision: 19241
Author:   [email protected]
Date:     Mon Feb 10 19:46:34 2014 UTC
Log:      MIPS: Add NaN test to cctest/test-macro-assembler-mips.

NaN value is different on MIPS and x86 architectures, and TEST(NaNx)
tests checks the case where a x86 NaN value is serialized into the snapshot
on the simulator during cross compilation.

BUG=
[email protected]

Review URL: https://codereview.chromium.org/144473008

Patch from Balazs Kilvady <[email protected]>.
http://code.google.com/p/v8/source/detail?r=19241

Modified:
 /branches/bleeding_edge/test/cctest/test-macro-assembler-mips.cc

=======================================
--- /branches/bleeding_edge/test/cctest/test-macro-assembler-mips.cc Mon Sep 23 19:38:54 2013 UTC +++ /branches/bleeding_edge/test/cctest/test-macro-assembler-mips.cc Mon Feb 10 19:46:34 2014 UTC
@@ -132,5 +132,47 @@
 }


+static void TestNaN(const char *code) {
+  // NaN value is different on MIPS and x86 architectures, and TEST(NaNx)
+  // tests checks the case where a x86 NaN value is serialized into the
+  // snapshot on the simulator during cross compilation.
+  v8::HandleScope scope(CcTest::isolate());
+  v8::Local<v8::Context> context = CcTest::NewContext(PRINT_EXTENSION);
+  v8::Context::Scope context_scope(context);
+
+  v8::Local<v8::Script> script = v8::Script::Compile(v8_str(code));
+ v8::Local<v8::Object> result = v8::Local<v8::Object>::Cast(script->Run());
+  // Have to populate the handle manually, as it's not Cast-able.
+  i::Handle<i::JSObject> o =
+      v8::Utils::OpenHandle<v8::Object, i::JSObject>(result);
+  i::Handle<i::JSArray> array1(reinterpret_cast<i::JSArray*>(*o));
+  i::FixedDoubleArray* a = i::FixedDoubleArray::cast(array1->elements());
+  double value = a->get_scalar(0);
+  CHECK(std::isnan(value) &&
+        i::BitCast<uint64_t>(value) ==
+        i::BitCast<uint64_t>(
+            i::FixedDoubleArray::canonical_not_the_hole_nan_as_double()));
+}
+
+
+TEST(NaN0) {
+  TestNaN(
+          "var result;"
+          "for (var i = 0; i < 2; i++) {"
+          "  result = new Array(Number.NaN, Number.POSITIVE_INFINITY);"
+          "}"
+          "result;");
+}
+
+
+TEST(NaN1) {
+  TestNaN(
+          "var result;"
+          "for (var i = 0; i < 2; i++) {"
+          "  result = [NaN];"
+          "}"
+          "result;");
+}
+

 #undef __

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to