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

Side by Side Diff: test/cctest/test-api.cc

Issue 6303012: Truncate rather than round to nearest when performing float-to-integer... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« src/ia32/stub-cache-ia32.cc ('K') | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 10569 matching lines...) Expand 10 before | Expand all | Expand 10 after
10580 result = CompileRun("for (var i = 0; i < 8; i++) {" 10580 result = CompileRun("for (var i = 0; i < 8; i++) {"
10581 " ext_array[i] = 5;" 10581 " ext_array[i] = 5;"
10582 "}" 10582 "}"
10583 "for (var i = 0; i < 8; i++) {" 10583 "for (var i = 0; i < 8; i++) {"
10584 " ext_array[i] = -Infinity;" 10584 " ext_array[i] = -Infinity;"
10585 "}" 10585 "}"
10586 "ext_array[5];"); 10586 "ext_array[5];");
10587 CHECK_EQ(0, result->Int32Value()); 10587 CHECK_EQ(0, result->Int32Value());
10588 CHECK_EQ(0, 10588 CHECK_EQ(0,
10589 i::Smi::cast(jsobj->GetElement(5)->ToObjectChecked())->value()); 10589 i::Smi::cast(jsobj->GetElement(5)->ToObjectChecked())->value());
10590
10591 // Check truncation behavior of integral arrays.
10592 const char* unsigned_data =
10593 "var source_data = [0.6, 10.6];"
10594 "var expected_results = [0, 10];";
10595 const char* signed_data =
10596 "var source_data = [0.6, 10.6, -0.6, -10.6];"
10597 "var expected_results = [0, 10, 0, -10];";
10598 bool is_unsigned =
10599 (array_type == v8::kExternalUnsignedByteArray ||
10600 array_type == v8::kExternalUnsignedShortArray ||
10601 array_type == v8::kExternalUnsignedIntArray);
10602
10603 i::OS::SNPrintF(test_buf,
10604 "%s"
10605 "var all_passed = true;"
10606 "for (var i = 0; i < source_data.length; i++) {"
10607 " for (var j = 0; j < 8; j++) {"
10608 " ext_array[j] = source_data[i];"
10609 " }"
10610 " all_passed = all_passed &&"
10611 " (ext_array[5] == expected_results[i]);"
10612 "}"
10613 "all_passed;",
10614 (is_unsigned ? unsigned_data : signed_data));
10615 result = CompileRun(test_buf.start());
10616 CHECK_EQ(true, result->BooleanValue());
10590 } 10617 }
10591 10618
10592 result = CompileRun("ext_array[3] = 33;" 10619 result = CompileRun("ext_array[3] = 33;"
10593 "delete ext_array[3];" 10620 "delete ext_array[3];"
10594 "ext_array[3];"); 10621 "ext_array[3];");
10595 CHECK_EQ(33, result->Int32Value()); 10622 CHECK_EQ(33, result->Int32Value());
10596 10623
10597 result = CompileRun("ext_array[0] = 10; ext_array[1] = 11;" 10624 result = CompileRun("ext_array[0] = 10; ext_array[1] = 11;"
10598 "ext_array[2] = 12; ext_array[3] = 13;" 10625 "ext_array[2] = 12; ext_array[3] = 13;"
10599 "ext_array.__defineGetter__('2'," 10626 "ext_array.__defineGetter__('2',"
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after
12170 v8::Context::Scope context_scope(context.local()); 12197 v8::Context::Scope context_scope(context.local());
12171 12198
12172 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); 12199 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New();
12173 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); 12200 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator);
12174 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); 12201 context->Global()->Set(v8_str("o"), tmpl->NewInstance());
12175 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( 12202 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
12176 "var result = []; for (var k in o) result.push(k); result")); 12203 "var result = []; for (var k in o) result.push(k); result"));
12177 CHECK_EQ(1, result->Length()); 12204 CHECK_EQ(1, result->Length());
12178 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); 12205 CHECK_EQ(v8_str("universalAnswer"), result->Get(0));
12179 } 12206 }
OLDNEW
« src/ia32/stub-cache-ia32.cc ('K') | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698