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

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

Issue 1506753002: [test] Test expectations in cctest should use CHECK and not DCHECK. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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 | « 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 2940 matching lines...) Expand 10 before | Expand all | Expand 10 after
2951 CheckInternalFieldsAreZero(ab); 2951 CheckInternalFieldsAreZero(ab);
2952 CHECK_EQ(1024, static_cast<int>(ab->ByteLength())); 2952 CHECK_EQ(1024, static_cast<int>(ab->ByteLength()));
2953 CHECK(!ab->IsExternal()); 2953 CHECK(!ab->IsExternal());
2954 CcTest::heap()->CollectAllGarbage(); 2954 CcTest::heap()->CollectAllGarbage();
2955 2955
2956 ScopedArrayBufferContents ab_contents(ab->Externalize()); 2956 ScopedArrayBufferContents ab_contents(ab->Externalize());
2957 CHECK(ab->IsExternal()); 2957 CHECK(ab->IsExternal());
2958 2958
2959 CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength())); 2959 CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength()));
2960 uint8_t* data = static_cast<uint8_t*>(ab_contents.Data()); 2960 uint8_t* data = static_cast<uint8_t*>(ab_contents.Data());
2961 DCHECK(data != NULL); 2961 CHECK(data != NULL);
2962 CHECK(env->Global()->Set(env.local(), v8_str("ab"), ab).FromJust()); 2962 CHECK(env->Global()->Set(env.local(), v8_str("ab"), ab).FromJust());
2963 2963
2964 v8::Local<v8::Value> result = CompileRun("ab.byteLength"); 2964 v8::Local<v8::Value> result = CompileRun("ab.byteLength");
2965 CHECK_EQ(1024, result->Int32Value(env.local()).FromJust()); 2965 CHECK_EQ(1024, result->Int32Value(env.local()).FromJust());
2966 2966
2967 result = CompileRun( 2967 result = CompileRun(
2968 "var u8 = new Uint8Array(ab);" 2968 "var u8 = new Uint8Array(ab);"
2969 "u8[0] = 0xFF;" 2969 "u8[0] = 0xFF;"
2970 "u8[1] = 0xAA;" 2970 "u8[1] = 0xAA;"
2971 "u8.length"); 2971 "u8.length");
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
3227 CheckInternalFieldsAreZero(ab); 3227 CheckInternalFieldsAreZero(ab);
3228 CHECK_EQ(1024, static_cast<int>(ab->ByteLength())); 3228 CHECK_EQ(1024, static_cast<int>(ab->ByteLength()));
3229 CHECK(!ab->IsExternal()); 3229 CHECK(!ab->IsExternal());
3230 CcTest::heap()->CollectAllGarbage(); 3230 CcTest::heap()->CollectAllGarbage();
3231 3231
3232 ScopedSharedArrayBufferContents ab_contents(ab->Externalize()); 3232 ScopedSharedArrayBufferContents ab_contents(ab->Externalize());
3233 CHECK(ab->IsExternal()); 3233 CHECK(ab->IsExternal());
3234 3234
3235 CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength())); 3235 CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength()));
3236 uint8_t* data = static_cast<uint8_t*>(ab_contents.Data()); 3236 uint8_t* data = static_cast<uint8_t*>(ab_contents.Data());
3237 DCHECK(data != NULL); 3237 CHECK(data != NULL);
3238 CHECK(env->Global()->Set(env.local(), v8_str("ab"), ab).FromJust()); 3238 CHECK(env->Global()->Set(env.local(), v8_str("ab"), ab).FromJust());
3239 3239
3240 v8::Local<v8::Value> result = CompileRun("ab.byteLength"); 3240 v8::Local<v8::Value> result = CompileRun("ab.byteLength");
3241 CHECK_EQ(1024, result->Int32Value(env.local()).FromJust()); 3241 CHECK_EQ(1024, result->Int32Value(env.local()).FromJust());
3242 3242
3243 result = CompileRun( 3243 result = CompileRun(
3244 "var u8 = new Uint8Array(ab);" 3244 "var u8 = new Uint8Array(ab);"
3245 "u8[0] = 0xFF;" 3245 "u8[0] = 0xFF;"
3246 "u8[1] = 0xAA;" 3246 "u8[1] = 0xAA;"
3247 "u8.length"); 3247 "u8.length");
(...skipping 7321 matching lines...) Expand 10 before | Expand all | Expand 10 after
10569 Local<Object> p = t->GetFunction(context.local()) 10569 Local<Object> p = t->GetFunction(context.local())
10570 .ToLocalChecked() 10570 .ToLocalChecked()
10571 ->NewInstance(context.local()) 10571 ->NewInstance(context.local())
10572 .ToLocalChecked(); 10572 .ToLocalChecked();
10573 Local<Object> o = Object::New(context->GetIsolate()); 10573 Local<Object> o = Object::New(context->GetIsolate());
10574 CHECK(o->SetPrototype(context.local(), p).FromJust()); 10574 CHECK(o->SetPrototype(context.local(), p).FromJust());
10575 10575
10576 int hash = o->GetIdentityHash(); 10576 int hash = o->GetIdentityHash();
10577 USE(hash); 10577 USE(hash);
10578 CHECK(o->Set(context.local(), v8_str("foo"), v8_num(42)).FromJust()); 10578 CHECK(o->Set(context.local(), v8_str("foo"), v8_num(42)).FromJust());
10579 DCHECK_EQ(hash, o->GetIdentityHash()); 10579 CHECK_EQ(hash, o->GetIdentityHash());
10580 } 10580 }
10581 10581
10582 10582
10583 THREADED_TEST(SetPrototype) { 10583 THREADED_TEST(SetPrototype) {
10584 LocalContext context; 10584 LocalContext context;
10585 v8::Isolate* isolate = context->GetIsolate(); 10585 v8::Isolate* isolate = context->GetIsolate();
10586 v8::HandleScope handle_scope(isolate); 10586 v8::HandleScope handle_scope(isolate);
10587 10587
10588 Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate); 10588 Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New(isolate);
10589 t0->InstanceTemplate()->Set(v8_str("x"), v8_num(0)); 10589 t0->InstanceTemplate()->Set(v8_str("x"), v8_num(0));
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
10878 .ToLocalChecked() 10878 .ToLocalChecked()
10879 ->NewInstance(context.local()) 10879 ->NewInstance(context.local())
10880 .ToLocalChecked(); 10880 .ToLocalChecked();
10881 10881
10882 CHECK(o0->SetPrototype(context.local(), o1).FromJust()); 10882 CHECK(o0->SetPrototype(context.local(), o1).FromJust());
10883 // If setting the prototype leads to the cycle, SetPrototype should 10883 // If setting the prototype leads to the cycle, SetPrototype should
10884 // return false and keep VM in sane state. 10884 // return false and keep VM in sane state.
10885 v8::TryCatch try_catch(isolate); 10885 v8::TryCatch try_catch(isolate);
10886 CHECK(o1->SetPrototype(context.local(), o0).IsNothing()); 10886 CHECK(o1->SetPrototype(context.local(), o0).IsNothing());
10887 CHECK(!try_catch.HasCaught()); 10887 CHECK(!try_catch.HasCaught());
10888 DCHECK(!CcTest::i_isolate()->has_pending_exception()); 10888 CHECK(!CcTest::i_isolate()->has_pending_exception());
10889 10889
10890 CHECK_EQ(42, CompileRun("function f() { return 42; }; f()") 10890 CHECK_EQ(42, CompileRun("function f() { return 42; }; f()")
10891 ->Int32Value(context.local()) 10891 ->Int32Value(context.local())
10892 .FromJust()); 10892 .FromJust());
10893 } 10893 }
10894 10894
10895 10895
10896 THREADED_TEST(FunctionRemovePrototype) { 10896 THREADED_TEST(FunctionRemovePrototype) {
10897 LocalContext context; 10897 LocalContext context;
10898 v8::Isolate* isolate = context->GetIsolate(); 10898 v8::Isolate* isolate = context->GetIsolate();
(...skipping 2847 matching lines...) Expand 10 before | Expand all | Expand 10 after
13746 " for (i = 0; i < 100; ++i)\n" 13746 " for (i = 0; i < 100; ++i)\n"
13747 " sum = foo(i);\n" 13747 " sum = foo(i);\n"
13748 " return sum;\n" 13748 " return sum;\n"
13749 "}\n" 13749 "}\n"
13750 "function foo(i) { return i * i; }\n" 13750 "function foo(i) { return i * i; }\n"
13751 "// Invoke on the runtime function.\n" 13751 "// Invoke on the runtime function.\n"
13752 "obj.asdf()"; 13752 "obj.asdf()";
13753 CompileRun(script); 13753 CompileRun(script);
13754 bar_func_ = i::Handle<i::JSFunction>::cast( 13754 bar_func_ = i::Handle<i::JSFunction>::cast(
13755 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("bar")))); 13755 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("bar"))));
13756 DCHECK(!bar_func_.is_null()); 13756 CHECK(!bar_func_.is_null());
13757 13757
13758 foo_func_ = 13758 foo_func_ =
13759 i::Handle<i::JSFunction>::cast( 13759 i::Handle<i::JSFunction>::cast(
13760 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("foo")))); 13760 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("foo"))));
13761 DCHECK(!foo_func_.is_null()); 13761 CHECK(!foo_func_.is_null());
13762 13762
13763 v8::Local<v8::Value> value = CompileRun("bar();"); 13763 v8::Local<v8::Value> value = CompileRun("bar();");
13764 CHECK(value->IsNumber()); 13764 CHECK(value->IsNumber());
13765 CHECK_EQ(9801.0, v8::Number::Cast(*value)->Value()); 13765 CHECK_EQ(9801.0, v8::Number::Cast(*value)->Value());
13766 13766
13767 // Test the optimized codegen path. 13767 // Test the optimized codegen path.
13768 value = CompileRun("%OptimizeFunctionOnNextCall(foo);" 13768 value = CompileRun("%OptimizeFunctionOnNextCall(foo);"
13769 "bar();"); 13769 "bar();");
13770 CHECK(value->IsNumber()); 13770 CHECK(value->IsNumber());
13771 CHECK_EQ(9801.0, v8::Number::Cast(*value)->Value()); 13771 CHECK_EQ(9801.0, v8::Number::Cast(*value)->Value());
(...skipping 2179 matching lines...) Expand 10 before | Expand all | Expand 10 after
15951 v8::HandleScope scope(args.GetIsolate()); 15951 v8::HandleScope scope(args.GetIsolate());
15952 const char* origin = "capture-stack-trace-test"; 15952 const char* origin = "capture-stack-trace-test";
15953 const int kOverviewTest = 1; 15953 const int kOverviewTest = 1;
15954 const int kDetailedTest = 2; 15954 const int kDetailedTest = 2;
15955 const int kFunctionName = 3; 15955 const int kFunctionName = 3;
15956 const int kDisplayName = 4; 15956 const int kDisplayName = 4;
15957 const int kFunctionNameAndDisplayName = 5; 15957 const int kFunctionNameAndDisplayName = 5;
15958 const int kDisplayNameIsNotString = 6; 15958 const int kDisplayNameIsNotString = 6;
15959 const int kFunctionNameIsNotString = 7; 15959 const int kFunctionNameIsNotString = 7;
15960 15960
15961 DCHECK(args.Length() == 1); 15961 CHECK(args.Length() == 1);
15962 15962
15963 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); 15963 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
15964 int testGroup = args[0]->Int32Value(context).FromJust(); 15964 int testGroup = args[0]->Int32Value(context).FromJust();
15965 if (testGroup == kOverviewTest) { 15965 if (testGroup == kOverviewTest) {
15966 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( 15966 v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
15967 args.GetIsolate(), 10, v8::StackTrace::kOverview); 15967 args.GetIsolate(), 10, v8::StackTrace::kOverview);
15968 CHECK_EQ(4, stackTrace->GetFrameCount()); 15968 CHECK_EQ(4, stackTrace->GetFrameCount());
15969 checkStackFrame(origin, "bar", 2, 10, false, false, 15969 checkStackFrame(origin, "bar", 2, 10, false, false,
15970 stackTrace->GetFrame(0)); 15970 stackTrace->GetFrame(0));
15971 checkStackFrame(origin, "foo", 6, 3, false, false, 15971 checkStackFrame(origin, "foo", 6, 3, false, false,
(...skipping 5648 matching lines...) Expand 10 before | Expand all | Expand 10 after
21620 "check = function(returned) {\n" 21620 "check = function(returned) {\n"
21621 " if (returned !== 1) { throw returned; }\n" 21621 " if (returned !== 1) { throw returned; }\n"
21622 "}\n" 21622 "}\n"
21623 "check(wrap_set());\n" 21623 "check(wrap_set());\n"
21624 "check(wrap_set());\n" 21624 "check(wrap_set());\n"
21625 "%%OptimizeFunctionOnNextCall(wrap_set_%d);\n" 21625 "%%OptimizeFunctionOnNextCall(wrap_set_%d);\n"
21626 "check(wrap_set());\n", 21626 "check(wrap_set());\n",
21627 wrap_function.start(), key, key, key, key, key, key); 21627 wrap_function.start(), key, key, key, key, key, key);
21628 v8::TryCatch try_catch(isolate); 21628 v8::TryCatch try_catch(isolate);
21629 CompileRun(source.start()); 21629 CompileRun(source.start());
21630 DCHECK(!try_catch.HasCaught()); 21630 CHECK(!try_catch.HasCaught());
21631 CHECK_EQ(9, count); 21631 CHECK_EQ(9, count);
21632 } 21632 }
21633 }; 21633 };
21634 21634
21635 21635
21636 Local<Object> ApiCallOptimizationChecker::data; 21636 Local<Object> ApiCallOptimizationChecker::data;
21637 Local<Object> ApiCallOptimizationChecker::receiver; 21637 Local<Object> ApiCallOptimizationChecker::receiver;
21638 Local<Object> ApiCallOptimizationChecker::holder; 21638 Local<Object> ApiCallOptimizationChecker::holder;
21639 Local<Object> ApiCallOptimizationChecker::callee; 21639 Local<Object> ApiCallOptimizationChecker::callee;
21640 int ApiCallOptimizationChecker::count = 0; 21640 int ApiCallOptimizationChecker::count = 0;
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
22858 isolate2->Dispose(); 22858 isolate2->Dispose();
22859 } 22859 }
22860 22860
22861 22861
22862 void TestInvalidCacheData(v8::ScriptCompiler::CompileOptions option) { 22862 void TestInvalidCacheData(v8::ScriptCompiler::CompileOptions option) {
22863 const char* garbage = "garbage garbage garbage garbage garbage garbage"; 22863 const char* garbage = "garbage garbage garbage garbage garbage garbage";
22864 const uint8_t* data = reinterpret_cast<const uint8_t*>(garbage); 22864 const uint8_t* data = reinterpret_cast<const uint8_t*>(garbage);
22865 int length = 16; 22865 int length = 16;
22866 v8::ScriptCompiler::CachedData* cached_data = 22866 v8::ScriptCompiler::CachedData* cached_data =
22867 new v8::ScriptCompiler::CachedData(data, length); 22867 new v8::ScriptCompiler::CachedData(data, length);
22868 DCHECK(!cached_data->rejected); 22868 CHECK(!cached_data->rejected);
22869 v8::ScriptOrigin origin(v8_str("origin")); 22869 v8::ScriptOrigin origin(v8_str("origin"));
22870 v8::ScriptCompiler::Source source(v8_str("42"), origin, cached_data); 22870 v8::ScriptCompiler::Source source(v8_str("42"), origin, cached_data);
22871 v8::Local<v8::Script> script = 22871 v8::Local<v8::Script> script =
22872 v8::ScriptCompiler::Compile(CcTest::isolate(), &source, option); 22872 v8::ScriptCompiler::Compile(CcTest::isolate(), &source, option);
22873 CHECK(cached_data->rejected); 22873 CHECK(cached_data->rejected);
22874 CHECK_EQ(42, script->Run() 22874 CHECK_EQ(42, script->Run()
22875 ->Int32Value(CcTest::isolate()->GetCurrentContext()) 22875 ->Int32Value(CcTest::isolate()->GetCurrentContext())
22876 .FromJust()); 22876 .FromJust());
22877 } 22877 }
22878 22878
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
23825 env2->Global()->Set(env2.local(), v8_str("obj2"), object2).FromJust()); 23825 env2->Global()->Set(env2.local(), v8_str("obj2"), object2).FromJust());
23826 ExpectString("typeof obj2.values", "function"); 23826 ExpectString("typeof obj2.values", "function");
23827 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values"))); 23827 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values")));
23828 23828
23829 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values"))); 23829 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values")));
23830 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2)); 23830 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2));
23831 auto ctx2 = v8::Utils::OpenHandle(*env2.local()); 23831 auto ctx2 = v8::Utils::OpenHandle(*env2.local());
23832 CHECK_EQ(fn2->GetCreationContext(), *ctx2); 23832 CHECK_EQ(fn2->GetCreationContext(), *ctx2);
23833 } 23833 }
23834 } 23834 }
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