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

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

Issue 7911: Various API changes (Closed)
Patch Set: "Various API changes Created 12 years, 1 month 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
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-heap.cc » ('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-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 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 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 CHECK_EQ(*exception_value, "panama!"); 1212 CHECK_EQ(*exception_value, "panama!");
1213 } 1213 }
1214 1214
1215 1215
1216 bool message_received; 1216 bool message_received;
1217 1217
1218 1218
1219 static void check_message(v8::Handle<v8::Message> message, 1219 static void check_message(v8::Handle<v8::Message> message,
1220 v8::Handle<Value> data) { 1220 v8::Handle<Value> data) {
1221 CHECK_EQ(5.76, data->NumberValue()); 1221 CHECK_EQ(5.76, data->NumberValue());
1222 CHECK_EQ(6.75, message->GetSourceData()->NumberValue()); 1222 CHECK_EQ(6.75, message->GetScriptResourceName()->NumberValue());
1223 message_received = true; 1223 message_received = true;
1224 } 1224 }
1225 1225
1226 1226
1227 THREADED_TEST(MessageHandlerData) { 1227 THREADED_TEST(MessageHandlerData) {
1228 message_received = false; 1228 message_received = false;
1229 v8::HandleScope scope; 1229 v8::HandleScope scope;
1230 CHECK(!message_received); 1230 CHECK(!message_received);
1231 v8::V8::AddMessageListener(check_message, v8_num(5.76)); 1231 v8::V8::AddMessageListener(check_message, v8_num(5.76));
1232 LocalContext context; 1232 LocalContext context;
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
2358 last_location = NULL; 2358 last_location = NULL;
2359 Local<Value> result = script->Run(); 2359 Local<Value> result = script->Run();
2360 2360
2361 CHECK(false); // Should not return. 2361 CHECK(false); // Should not return.
2362 } 2362 }
2363 2363
2364 2364
2365 static void MissingScriptInfoMessageListener(v8::Handle<v8::Message> message, 2365 static void MissingScriptInfoMessageListener(v8::Handle<v8::Message> message,
2366 v8::Handle<Value> data) { 2366 v8::Handle<Value> data) {
2367 CHECK_EQ(v8::Undefined(), data); 2367 CHECK_EQ(v8::Undefined(), data);
2368 CHECK(message->GetScriptResourceName().IsEmpty()); 2368 CHECK(message->GetScriptResourceName()->IsUndefined());
2369 CHECK_EQ(v8::Undefined(), message->GetSourceData()); 2369 CHECK_EQ(v8::Undefined(), message->GetScriptResourceName());
2370 message->GetLineNumber(); 2370 message->GetLineNumber();
2371 message->GetSourceLine(); 2371 message->GetSourceLine();
2372 } 2372 }
2373 2373
2374 2374
2375 THREADED_TEST(ErrorWithMissingScriptInfo) { 2375 THREADED_TEST(ErrorWithMissingScriptInfo) {
2376 v8::HandleScope scope; 2376 v8::HandleScope scope;
2377 LocalContext context; 2377 LocalContext context;
2378 v8::V8::AddMessageListener(MissingScriptInfoMessageListener); 2378 v8::V8::AddMessageListener(MissingScriptInfoMessageListener);
2379 Script::Compile(v8_str("throw Error()"))->Run(); 2379 Script::Compile(v8_str("throw Error()"))->Run();
(...skipping 23 matching lines...) Expand all
2403 return Local<Script>(*script_); 2403 return Local<Script>(*script_);
2404 } 2404 }
2405 2405
2406 public: 2406 public:
2407 static const int kObjectCount = 256; 2407 static const int kObjectCount = 256;
2408 int cursor_; 2408 int cursor_;
2409 v8::Persistent<v8::Object> objects_[kObjectCount]; 2409 v8::Persistent<v8::Object> objects_[kObjectCount];
2410 v8::Persistent<Script> script_; 2410 v8::Persistent<Script> script_;
2411 }; 2411 };
2412 2412
2413 static void HandleWeakReference(v8::Persistent<v8::Object> obj, void* data) { 2413 static void HandleWeakReference(v8::Persistent<v8::Value> obj, void* data) {
2414 Snorkel* snorkel = reinterpret_cast<Snorkel*>(data); 2414 Snorkel* snorkel = reinterpret_cast<Snorkel*>(data);
2415 delete snorkel; 2415 delete snorkel;
2416 obj.ClearWeak(); 2416 obj.ClearWeak();
2417 } 2417 }
2418 2418
2419 v8::Handle<Value> WhammyPropertyGetter(Local<String> name, 2419 v8::Handle<Value> WhammyPropertyGetter(Local<String> name,
2420 const AccessorInfo& info) { 2420 const AccessorInfo& info) {
2421 Whammy* whammy = 2421 Whammy* whammy =
2422 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value()); 2422 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value());
2423 2423
(...skipping 2593 matching lines...) Expand 10 before | Expand all | Expand 10 after
5017 v8::HandleScope scope; 5017 v8::HandleScope scope;
5018 LocalContext context; 5018 LocalContext context;
5019 Local<ObjectTemplate> t = ObjectTemplate::New(); 5019 Local<ObjectTemplate> t = ObjectTemplate::New();
5020 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(FunctionNameCallback)); 5020 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(FunctionNameCallback));
5021 context->Global()->Set(v8_str("obj"), t->NewInstance()); 5021 context->Global()->Set(v8_str("obj"), t->NewInstance());
5022 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name"); 5022 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name");
5023 CHECK(value->IsString()); 5023 CHECK(value->IsString());
5024 v8::String::AsciiValue name(value); 5024 v8::String::AsciiValue name(value);
5025 CHECK_EQ("asdf", *name); 5025 CHECK_EQ("asdf", *name);
5026 } 5026 }
5027
5028
5029 THREADED_TEST(DateAccess) {
5030 v8::HandleScope scope;
5031 LocalContext context;
5032 v8::Handle<v8::Value> date = v8::Date::New(1224744689038.0);
5033 CHECK(date->IsDate());
5034 CHECK_EQ(1224744689038.0, v8::Handle<v8::Date>::Cast(date)->NumberValue());
5035 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698