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

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

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 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/test-alloc.cc ('k') | test/cctest/test-assembler-arm.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 2954 matching lines...) Expand 10 before | Expand all | Expand 10 after
2965 CheckInternalFieldsAreZero(ab); 2965 CheckInternalFieldsAreZero(ab);
2966 CHECK_EQ(1024, static_cast<int>(ab->ByteLength())); 2966 CHECK_EQ(1024, static_cast<int>(ab->ByteLength()));
2967 CHECK(!ab->IsExternal()); 2967 CHECK(!ab->IsExternal());
2968 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); 2968 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
2969 2969
2970 ScopedArrayBufferContents ab_contents(ab->Externalize()); 2970 ScopedArrayBufferContents ab_contents(ab->Externalize());
2971 CHECK(ab->IsExternal()); 2971 CHECK(ab->IsExternal());
2972 2972
2973 CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength())); 2973 CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength()));
2974 uint8_t* data = static_cast<uint8_t*>(ab_contents.Data()); 2974 uint8_t* data = static_cast<uint8_t*>(ab_contents.Data());
2975 ASSERT(data != NULL); 2975 DCHECK(data != NULL);
2976 env->Global()->Set(v8_str("ab"), ab); 2976 env->Global()->Set(v8_str("ab"), ab);
2977 2977
2978 v8::Handle<v8::Value> result = CompileRun("ab.byteLength"); 2978 v8::Handle<v8::Value> result = CompileRun("ab.byteLength");
2979 CHECK_EQ(1024, result->Int32Value()); 2979 CHECK_EQ(1024, result->Int32Value());
2980 2980
2981 result = CompileRun("var u8 = new Uint8Array(ab);" 2981 result = CompileRun("var u8 = new Uint8Array(ab);"
2982 "u8[0] = 0xFF;" 2982 "u8[0] = 0xFF;"
2983 "u8[1] = 0xAA;" 2983 "u8[1] = 0xAA;"
2984 "u8.length"); 2984 "u8.length");
2985 CHECK_EQ(1024, result->Int32Value()); 2985 CHECK_EQ(1024, result->Int32Value());
(...skipping 7195 matching lines...) Expand 10 before | Expand all | Expand 10 after
10181 Handle<FunctionTemplate> t = FunctionTemplate::New(context->GetIsolate()); 10181 Handle<FunctionTemplate> t = FunctionTemplate::New(context->GetIsolate());
10182 t->SetHiddenPrototype(true); 10182 t->SetHiddenPrototype(true);
10183 t->InstanceTemplate()->Set(v8_str("foo"), v8_num(75)); 10183 t->InstanceTemplate()->Set(v8_str("foo"), v8_num(75));
10184 Handle<Object> p = t->GetFunction()->NewInstance(); 10184 Handle<Object> p = t->GetFunction()->NewInstance();
10185 Handle<Object> o = Object::New(context->GetIsolate()); 10185 Handle<Object> o = Object::New(context->GetIsolate());
10186 o->SetPrototype(p); 10186 o->SetPrototype(p);
10187 10187
10188 int hash = o->GetIdentityHash(); 10188 int hash = o->GetIdentityHash();
10189 USE(hash); 10189 USE(hash);
10190 o->Set(v8_str("foo"), v8_num(42)); 10190 o->Set(v8_str("foo"), v8_num(42));
10191 ASSERT_EQ(hash, o->GetIdentityHash()); 10191 DCHECK_EQ(hash, o->GetIdentityHash());
10192 } 10192 }
10193 10193
10194 10194
10195 THREADED_TEST(SetPrototype) { 10195 THREADED_TEST(SetPrototype) {
10196 LocalContext context; 10196 LocalContext context;
10197 v8::Isolate* isolate = context->GetIsolate(); 10197 v8::Isolate* isolate = context->GetIsolate();
10198 v8::HandleScope handle_scope(isolate); 10198 v8::HandleScope handle_scope(isolate);
10199 10199
10200 Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate); 10200 Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
10201 t0->InstanceTemplate()->Set(v8_str("x"), v8_num(0)); 10201 t0->InstanceTemplate()->Set(v8_str("x"), v8_num(0));
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
10404 10404
10405 Local<v8::Object> o0 = t->GetFunction()->NewInstance(); 10405 Local<v8::Object> o0 = t->GetFunction()->NewInstance();
10406 Local<v8::Object> o1 = t->GetFunction()->NewInstance(); 10406 Local<v8::Object> o1 = t->GetFunction()->NewInstance();
10407 10407
10408 CHECK(o0->SetPrototype(o1)); 10408 CHECK(o0->SetPrototype(o1));
10409 // If setting the prototype leads to the cycle, SetPrototype should 10409 // If setting the prototype leads to the cycle, SetPrototype should
10410 // return false and keep VM in sane state. 10410 // return false and keep VM in sane state.
10411 v8::TryCatch try_catch; 10411 v8::TryCatch try_catch;
10412 CHECK(!o1->SetPrototype(o0)); 10412 CHECK(!o1->SetPrototype(o0));
10413 CHECK(!try_catch.HasCaught()); 10413 CHECK(!try_catch.HasCaught());
10414 ASSERT(!CcTest::i_isolate()->has_pending_exception()); 10414 DCHECK(!CcTest::i_isolate()->has_pending_exception());
10415 10415
10416 CHECK_EQ(42, CompileRun("function f() { return 42; }; f()")->Int32Value()); 10416 CHECK_EQ(42, CompileRun("function f() { return 42; }; f()")->Int32Value());
10417 } 10417 }
10418 10418
10419 10419
10420 THREADED_TEST(FunctionRemovePrototype) { 10420 THREADED_TEST(FunctionRemovePrototype) {
10421 LocalContext context; 10421 LocalContext context;
10422 v8::Isolate* isolate = context->GetIsolate(); 10422 v8::Isolate* isolate = context->GetIsolate();
10423 v8::HandleScope handle_scope(isolate); 10423 v8::HandleScope handle_scope(isolate);
10424 10424
(...skipping 3562 matching lines...) Expand 10 before | Expand all | Expand 10 after
13987 " for (i = 0; i < 100; ++i)\n" 13987 " for (i = 0; i < 100; ++i)\n"
13988 " sum = foo(i);\n" 13988 " sum = foo(i);\n"
13989 " return sum;\n" 13989 " return sum;\n"
13990 "}\n" 13990 "}\n"
13991 "function foo(i) { return i * i; }\n" 13991 "function foo(i) { return i * i; }\n"
13992 "// Invoke on the runtime function.\n" 13992 "// Invoke on the runtime function.\n"
13993 "obj.asdf()"; 13993 "obj.asdf()";
13994 CompileRun(script); 13994 CompileRun(script);
13995 bar_func_ = i::Handle<i::JSFunction>::cast( 13995 bar_func_ = i::Handle<i::JSFunction>::cast(
13996 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("bar")))); 13996 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("bar"))));
13997 ASSERT(!bar_func_.is_null()); 13997 DCHECK(!bar_func_.is_null());
13998 13998
13999 foo_func_ = 13999 foo_func_ =
14000 i::Handle<i::JSFunction>::cast( 14000 i::Handle<i::JSFunction>::cast(
14001 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("foo")))); 14001 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("foo"))));
14002 ASSERT(!foo_func_.is_null()); 14002 DCHECK(!foo_func_.is_null());
14003 14003
14004 v8::Handle<v8::Value> value = CompileRun("bar();"); 14004 v8::Handle<v8::Value> value = CompileRun("bar();");
14005 CHECK(value->IsNumber()); 14005 CHECK(value->IsNumber());
14006 CHECK_EQ(9801.0, v8::Number::Cast(*value)->Value()); 14006 CHECK_EQ(9801.0, v8::Number::Cast(*value)->Value());
14007 14007
14008 // Test the optimized codegen path. 14008 // Test the optimized codegen path.
14009 value = CompileRun("%OptimizeFunctionOnNextCall(foo);" 14009 value = CompileRun("%OptimizeFunctionOnNextCall(foo);"
14010 "bar();"); 14010 "bar();");
14011 CHECK(value->IsNumber()); 14011 CHECK(value->IsNumber());
14012 CHECK_EQ(9801.0, v8::Number::Cast(*value)->Value()); 14012 CHECK_EQ(9801.0, v8::Number::Cast(*value)->Value());
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after
15678 " sum += pixels[i];" 15678 " sum += pixels[i];"
15679 "}" 15679 "}"
15680 "sum;"); 15680 "sum;");
15681 CHECK_EQ(28, result->Int32Value()); 15681 CHECK_EQ(28, result->Int32Value());
15682 15682
15683 i::Handle<i::Smi> value(i::Smi::FromInt(2), 15683 i::Handle<i::Smi> value(i::Smi::FromInt(2),
15684 reinterpret_cast<i::Isolate*>(context->GetIsolate())); 15684 reinterpret_cast<i::Isolate*>(context->GetIsolate()));
15685 i::Handle<i::Object> no_failure; 15685 i::Handle<i::Object> no_failure;
15686 no_failure = i::JSObject::SetElement( 15686 no_failure = i::JSObject::SetElement(
15687 jsobj, 1, value, NONE, i::SLOPPY).ToHandleChecked(); 15687 jsobj, 1, value, NONE, i::SLOPPY).ToHandleChecked();
15688 ASSERT(!no_failure.is_null()); 15688 DCHECK(!no_failure.is_null());
15689 USE(no_failure); 15689 USE(no_failure);
15690 CheckElementValue(isolate, 2, jsobj, 1); 15690 CheckElementValue(isolate, 2, jsobj, 1);
15691 *value.location() = i::Smi::FromInt(256); 15691 *value.location() = i::Smi::FromInt(256);
15692 no_failure = i::JSObject::SetElement( 15692 no_failure = i::JSObject::SetElement(
15693 jsobj, 1, value, NONE, i::SLOPPY).ToHandleChecked(); 15693 jsobj, 1, value, NONE, i::SLOPPY).ToHandleChecked();
15694 ASSERT(!no_failure.is_null()); 15694 DCHECK(!no_failure.is_null());
15695 USE(no_failure); 15695 USE(no_failure);
15696 CheckElementValue(isolate, 255, jsobj, 1); 15696 CheckElementValue(isolate, 255, jsobj, 1);
15697 *value.location() = i::Smi::FromInt(-1); 15697 *value.location() = i::Smi::FromInt(-1);
15698 no_failure = i::JSObject::SetElement( 15698 no_failure = i::JSObject::SetElement(
15699 jsobj, 1, value, NONE, i::SLOPPY).ToHandleChecked(); 15699 jsobj, 1, value, NONE, i::SLOPPY).ToHandleChecked();
15700 ASSERT(!no_failure.is_null()); 15700 DCHECK(!no_failure.is_null());
15701 USE(no_failure); 15701 USE(no_failure);
15702 CheckElementValue(isolate, 0, jsobj, 1); 15702 CheckElementValue(isolate, 0, jsobj, 1);
15703 15703
15704 result = CompileRun("for (var i = 0; i < 8; i++) {" 15704 result = CompileRun("for (var i = 0; i < 8; i++) {"
15705 " pixels[i] = (i * 65) - 109;" 15705 " pixels[i] = (i * 65) - 109;"
15706 "}" 15706 "}"
15707 "pixels[1] + pixels[6];"); 15707 "pixels[1] + pixels[6];");
15708 CHECK_EQ(255, result->Int32Value()); 15708 CHECK_EQ(255, result->Int32Value());
15709 CheckElementValue(isolate, 0, jsobj, 0); 15709 CheckElementValue(isolate, 0, jsobj, 0);
15710 CheckElementValue(isolate, 0, jsobj, 1); 15710 CheckElementValue(isolate, 0, jsobj, 1);
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after
17062 CHECK_EQ(is_constructor, frame->IsConstructor()); 17062 CHECK_EQ(is_constructor, frame->IsConstructor());
17063 } 17063 }
17064 17064
17065 17065
17066 void AnalyzeStackInNativeCode(const v8::FunctionCallbackInfo<v8::Value>& args) { 17066 void AnalyzeStackInNativeCode(const v8::FunctionCallbackInfo<v8::Value>& args) {
17067 v8::HandleScope scope(args.GetIsolate()); 17067 v8::HandleScope scope(args.GetIsolate());
17068 const char* origin = "capture-stack-trace-test"; 17068 const char* origin = "capture-stack-trace-test";
17069 const int kOverviewTest = 1; 17069 const int kOverviewTest = 1;
17070 const int kDetailedTest = 2; 17070 const int kDetailedTest = 2;
17071 17071
17072 ASSERT(args.Length() == 1); 17072 DCHECK(args.Length() == 1);
17073 17073
17074 int testGroup = args[0]->Int32Value(); 17074 int testGroup = args[0]->Int32Value();
17075 if (testGroup == kOverviewTest) { 17075 if (testGroup == kOverviewTest) {
17076 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( 17076 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
17077 args.GetIsolate(), 10, v8::StackTrace::kOverview); 17077 args.GetIsolate(), 10, v8::StackTrace::kOverview);
17078 CHECK_EQ(4, stackTrace->GetFrameCount()); 17078 CHECK_EQ(4, stackTrace->GetFrameCount());
17079 checkStackFrame(origin, "bar", 2, 10, false, false, 17079 checkStackFrame(origin, "bar", 2, 10, false, false,
17080 stackTrace->GetFrame(0)); 17080 stackTrace->GetFrame(0));
17081 checkStackFrame(origin, "foo", 6, 3, false, false, 17081 checkStackFrame(origin, "foo", 6, 3, false, false,
17082 stackTrace->GetFrame(1)); 17082 stackTrace->GetFrame(1));
(...skipping 5309 matching lines...) Expand 10 before | Expand all | Expand 10 after
22392 "check = function(returned) {\n" 22392 "check = function(returned) {\n"
22393 " if (returned !== 1) { throw returned; }\n" 22393 " if (returned !== 1) { throw returned; }\n"
22394 "}\n" 22394 "}\n"
22395 "check(wrap_set());\n" 22395 "check(wrap_set());\n"
22396 "check(wrap_set());\n" 22396 "check(wrap_set());\n"
22397 "%%OptimizeFunctionOnNextCall(wrap_set_%d);\n" 22397 "%%OptimizeFunctionOnNextCall(wrap_set_%d);\n"
22398 "check(wrap_set());\n", 22398 "check(wrap_set());\n",
22399 wrap_function.start(), key, key, key, key, key, key); 22399 wrap_function.start(), key, key, key, key, key, key);
22400 v8::TryCatch try_catch; 22400 v8::TryCatch try_catch;
22401 CompileRun(source.start()); 22401 CompileRun(source.start());
22402 ASSERT(!try_catch.HasCaught()); 22402 DCHECK(!try_catch.HasCaught());
22403 CHECK_EQ(9, count); 22403 CHECK_EQ(9, count);
22404 } 22404 }
22405 }; 22405 };
22406 22406
22407 22407
22408 Local<Object> ApiCallOptimizationChecker::data; 22408 Local<Object> ApiCallOptimizationChecker::data;
22409 Local<Object> ApiCallOptimizationChecker::receiver; 22409 Local<Object> ApiCallOptimizationChecker::receiver;
22410 Local<Object> ApiCallOptimizationChecker::holder; 22410 Local<Object> ApiCallOptimizationChecker::holder;
22411 Local<Object> ApiCallOptimizationChecker::callee; 22411 Local<Object> ApiCallOptimizationChecker::callee;
22412 int ApiCallOptimizationChecker::count = 0; 22412 int ApiCallOptimizationChecker::count = 0;
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
22842 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); 22842 desc = x->GetOwnPropertyDescriptor(v8_str("p1"));
22843 Local<Function> set = 22843 Local<Function> set =
22844 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); 22844 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set")));
22845 Local<Function> get = 22845 Local<Function> get =
22846 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); 22846 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get")));
22847 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL)); 22847 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL));
22848 Handle<Value> args[] = { v8_num(14) }; 22848 Handle<Value> args[] = { v8_num(14) };
22849 set->Call(x, 1, args); 22849 set->Call(x, 1, args);
22850 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); 22850 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL));
22851 } 22851 }
OLDNEW
« no previous file with comments | « test/cctest/test-alloc.cc ('k') | test/cctest/test-assembler-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698