Index: test/cctest/test-api.cc |
=================================================================== |
--- test/cctest/test-api.cc (revision 6406) |
+++ test/cctest/test-api.cc (working copy) |
@@ -10587,6 +10587,33 @@ |
CHECK_EQ(0, result->Int32Value()); |
CHECK_EQ(0, |
i::Smi::cast(jsobj->GetElement(5)->ToObjectChecked())->value()); |
+ |
+ // Check truncation behavior of integral arrays. |
+ const char* unsigned_data = |
+ "var source_data = [0.6, 10.6];" |
+ "var expected_results = [0, 10];"; |
+ const char* signed_data = |
+ "var source_data = [0.6, 10.6, -0.6, -10.6];" |
+ "var expected_results = [0, 10, 0, -10];"; |
+ bool is_unsigned = |
+ (array_type == v8::kExternalUnsignedByteArray || |
+ array_type == v8::kExternalUnsignedShortArray || |
+ array_type == v8::kExternalUnsignedIntArray); |
+ |
+ i::OS::SNPrintF(test_buf, |
+ "%s" |
+ "var all_passed = true;" |
+ "for (var i = 0; i < source_data.length; i++) {" |
+ " for (var j = 0; j < 8; j++) {" |
+ " ext_array[j] = source_data[i];" |
+ " }" |
+ " all_passed = all_passed &&" |
+ " (ext_array[5] == expected_results[i]);" |
+ "}" |
+ "all_passed;", |
+ (is_unsigned ? unsigned_data : signed_data)); |
+ result = CompileRun(test_buf.start()); |
+ CHECK_EQ(true, result->BooleanValue()); |
} |
result = CompileRun("ext_array[3] = 33;" |