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

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

Issue 6322008: Version 3.0.10... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
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
« no previous file with comments | « test/cctest/cctest.status ('k') | test/mjsunit/cyclic-error-to-string.js » ('j') | 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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 expected_ptr = reinterpret_cast<void*>(1); 867 expected_ptr = reinterpret_cast<void*>(1);
868 TestExternalPointerWrapping(); 868 TestExternalPointerWrapping();
869 869
870 expected_ptr = reinterpret_cast<void*>(0xdeadbeef); 870 expected_ptr = reinterpret_cast<void*>(0xdeadbeef);
871 TestExternalPointerWrapping(); 871 TestExternalPointerWrapping();
872 872
873 expected_ptr = reinterpret_cast<void*>(0xdeadbeef + 1); 873 expected_ptr = reinterpret_cast<void*>(0xdeadbeef + 1);
874 TestExternalPointerWrapping(); 874 TestExternalPointerWrapping();
875 875
876 #if defined(V8_HOST_ARCH_X64) 876 #if defined(V8_HOST_ARCH_X64)
877 // Check a value with a leading 1 bit in x64 Smi encoding.
878 expected_ptr = reinterpret_cast<void*>(0x400000000);
879 TestExternalPointerWrapping();
880
877 expected_ptr = reinterpret_cast<void*>(0xdeadbeefdeadbeef); 881 expected_ptr = reinterpret_cast<void*>(0xdeadbeefdeadbeef);
878 TestExternalPointerWrapping(); 882 TestExternalPointerWrapping();
879 883
880 expected_ptr = reinterpret_cast<void*>(0xdeadbeefdeadbeef + 1); 884 expected_ptr = reinterpret_cast<void*>(0xdeadbeefdeadbeef + 1);
881 TestExternalPointerWrapping(); 885 TestExternalPointerWrapping();
882 #endif 886 #endif
883 } 887 }
884 888
885 889
886 THREADED_TEST(FindInstanceInPrototypeChain) { 890 THREADED_TEST(FindInstanceInPrototypeChain) {
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
2368 // Test that overwritten toString methods are not invoked on uncaught 2372 // Test that overwritten toString methods are not invoked on uncaught
2369 // exception formatting. However, they are invoked when performing 2373 // exception formatting. However, they are invoked when performing
2370 // normal error string conversions. 2374 // normal error string conversions.
2371 TEST(APIThrowMessageOverwrittenToString) { 2375 TEST(APIThrowMessageOverwrittenToString) {
2372 v8::HandleScope scope; 2376 v8::HandleScope scope;
2373 v8::V8::AddMessageListener(check_reference_error_message); 2377 v8::V8::AddMessageListener(check_reference_error_message);
2374 LocalContext context; 2378 LocalContext context;
2375 CompileRun("ReferenceError.prototype.toString =" 2379 CompileRun("ReferenceError.prototype.toString ="
2376 " function() { return 'Whoops' }"); 2380 " function() { return 'Whoops' }");
2377 CompileRun("asdf;"); 2381 CompileRun("asdf;");
2382 CompileRun("ReferenceError.prototype.constructor.name = void 0;");
2383 CompileRun("asdf;");
2384 CompileRun("ReferenceError.prototype.constructor = void 0;");
2385 CompileRun("asdf;");
2378 v8::Handle<Value> string = CompileRun("try { asdf; } catch(e) { e + ''; }"); 2386 v8::Handle<Value> string = CompileRun("try { asdf; } catch(e) { e + ''; }");
2379 CHECK(string->Equals(v8_str("Whoops"))); 2387 CHECK(string->Equals(v8_str("Whoops")));
2380 v8::V8::RemoveMessageListeners(check_message); 2388 v8::V8::RemoveMessageListeners(check_message);
2381 } 2389 }
2382 2390
2383 2391
2384 static void receive_message(v8::Handle<v8::Message> message, 2392 static void receive_message(v8::Handle<v8::Message> message,
2385 v8::Handle<v8::Value> data) { 2393 v8::Handle<v8::Value> data) {
2386 message->Get(); 2394 message->Get();
2387 message_received = true; 2395 message_received = true;
(...skipping 8188 matching lines...) Expand 10 before | Expand all | Expand 10 after
10576 result = CompileRun("for (var i = 0; i < 8; i++) {" 10584 result = CompileRun("for (var i = 0; i < 8; i++) {"
10577 " ext_array[i] = 5;" 10585 " ext_array[i] = 5;"
10578 "}" 10586 "}"
10579 "for (var i = 0; i < 8; i++) {" 10587 "for (var i = 0; i < 8; i++) {"
10580 " ext_array[i] = -Infinity;" 10588 " ext_array[i] = -Infinity;"
10581 "}" 10589 "}"
10582 "ext_array[5];"); 10590 "ext_array[5];");
10583 CHECK_EQ(0, result->Int32Value()); 10591 CHECK_EQ(0, result->Int32Value());
10584 CHECK_EQ(0, 10592 CHECK_EQ(0,
10585 i::Smi::cast(jsobj->GetElement(5)->ToObjectChecked())->value()); 10593 i::Smi::cast(jsobj->GetElement(5)->ToObjectChecked())->value());
10594
10595 // Check truncation behavior of integral arrays.
10596 const char* unsigned_data =
10597 "var source_data = [0.6, 10.6];"
10598 "var expected_results = [0, 10];";
10599 const char* signed_data =
10600 "var source_data = [0.6, 10.6, -0.6, -10.6];"
10601 "var expected_results = [0, 10, 0, -10];";
10602 bool is_unsigned =
10603 (array_type == v8::kExternalUnsignedByteArray ||
10604 array_type == v8::kExternalUnsignedShortArray ||
10605 array_type == v8::kExternalUnsignedIntArray);
10606
10607 i::OS::SNPrintF(test_buf,
10608 "%s"
10609 "var all_passed = true;"
10610 "for (var i = 0; i < source_data.length; i++) {"
10611 " for (var j = 0; j < 8; j++) {"
10612 " ext_array[j] = source_data[i];"
10613 " }"
10614 " all_passed = all_passed &&"
10615 " (ext_array[5] == expected_results[i]);"
10616 "}"
10617 "all_passed;",
10618 (is_unsigned ? unsigned_data : signed_data));
10619 result = CompileRun(test_buf.start());
10620 CHECK_EQ(true, result->BooleanValue());
10586 } 10621 }
10587 10622
10588 result = CompileRun("ext_array[3] = 33;" 10623 result = CompileRun("ext_array[3] = 33;"
10589 "delete ext_array[3];" 10624 "delete ext_array[3];"
10590 "ext_array[3];"); 10625 "ext_array[3];");
10591 CHECK_EQ(33, result->Int32Value()); 10626 CHECK_EQ(33, result->Int32Value());
10592 10627
10593 result = CompileRun("ext_array[0] = 10; ext_array[1] = 11;" 10628 result = CompileRun("ext_array[0] = 10; ext_array[1] = 11;"
10594 "ext_array[2] = 12; ext_array[3] = 13;" 10629 "ext_array[2] = 12; ext_array[3] = 13;"
10595 "ext_array.__defineGetter__('2'," 10630 "ext_array.__defineGetter__('2',"
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after
12166 v8::Context::Scope context_scope(context.local()); 12201 v8::Context::Scope context_scope(context.local());
12167 12202
12168 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); 12203 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New();
12169 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); 12204 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator);
12170 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); 12205 context->Global()->Set(v8_str("o"), tmpl->NewInstance());
12171 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( 12206 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
12172 "var result = []; for (var k in o) result.push(k); result")); 12207 "var result = []; for (var k in o) result.push(k); result"));
12173 CHECK_EQ(1, result->Length()); 12208 CHECK_EQ(1, result->Length());
12174 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); 12209 CHECK_EQ(v8_str("universalAnswer"), result->Get(0));
12175 } 12210 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.status ('k') | test/mjsunit/cyclic-error-to-string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698