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

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

Issue 1284413002: Add experimental, non-snapshotted V8 extras (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@non-experimental-extras
Patch Set: Missing gn entries Created 5 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
« no previous file with comments | « src/snapshot/natives-external.cc ('k') | test/cctest/test-experimental-extra.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 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 21598 matching lines...) Expand 10 before | Expand all | Expand 10 after
21609 } 21609 }
21610 obj->ForceSet(v8_str("foo"), v8_num(1), v8::None); 21610 obj->ForceSet(v8_str("foo"), v8_num(1), v8::None);
21611 obj->ForceSet(v8_str("2"), v8_num(1), v8::None); 21611 obj->ForceSet(v8_str("2"), v8_num(1), v8::None);
21612 CHECK(obj->HasOwnProperty(v8_str("foo"))); 21612 CHECK(obj->HasOwnProperty(v8_str("foo")));
21613 CHECK(obj->HasOwnProperty(v8_str("2"))); 21613 CHECK(obj->HasOwnProperty(v8_str("2")));
21614 CHECK(!obj->Delete(v8_str("foo"))); 21614 CHECK(!obj->Delete(v8_str("foo")));
21615 CHECK(!obj->Delete(2)); 21615 CHECK(!obj->Delete(2));
21616 } 21616 }
21617 21617
21618 21618
21619 static void ExtrasExportsTestRuntimeFunction( 21619 static void ExtrasBindingTestRuntimeFunction(
21620 const v8::FunctionCallbackInfo<v8::Value>& args) { 21620 const v8::FunctionCallbackInfo<v8::Value>& args) {
21621 CHECK_EQ(3, args[0]->Int32Value()); 21621 CHECK_EQ(3, args[0]->Int32Value());
21622 args.GetReturnValue().Set(v8_num(7)); 21622 args.GetReturnValue().Set(v8_num(7));
21623 } 21623 }
21624 21624
21625 21625
21626 TEST(ExtrasExportsObject) { 21626 TEST(ExtrasBindingObject) {
21627 v8::Isolate* isolate = CcTest::isolate(); 21627 v8::Isolate* isolate = CcTest::isolate();
21628 v8::HandleScope handle_scope(isolate); 21628 v8::HandleScope handle_scope(isolate);
21629 LocalContext env; 21629 LocalContext env;
21630 21630
21631 // standalone.gypi ensures we include the test-extra.js file, which should 21631 // standalone.gypi ensures we include the test-extra.js file, which should
21632 // export the tested functions. 21632 // export the tested functions.
21633 v8::Local<v8::Object> binding = env->GetExtrasBindingObject(); 21633 v8::Local<v8::Object> binding = env->GetExtrasBindingObject();
21634 21634
21635 auto func = 21635 auto func =
21636 binding->Get(v8_str("testExtraShouldReturnFive")).As<v8::Function>(); 21636 binding->Get(v8_str("testExtraShouldReturnFive")).As<v8::Function>();
21637 auto undefined = v8::Undefined(isolate); 21637 auto undefined = v8::Undefined(isolate);
21638 auto result = func->Call(undefined, 0, {}).As<v8::Number>(); 21638 auto result = func->Call(undefined, 0, {}).As<v8::Number>();
21639 CHECK_EQ(5, result->Int32Value()); 21639 CHECK_EQ(5, result->Int32Value());
21640 21640
21641 v8::Handle<v8::FunctionTemplate> runtimeFunction = 21641 v8::Handle<v8::FunctionTemplate> runtimeFunction =
21642 v8::FunctionTemplate::New(isolate, ExtrasExportsTestRuntimeFunction); 21642 v8::FunctionTemplate::New(isolate, ExtrasBindingTestRuntimeFunction);
21643 binding->Set(v8_str("runtime"), runtimeFunction->GetFunction()); 21643 binding->Set(v8_str("runtime"), runtimeFunction->GetFunction());
21644 func = 21644 func =
21645 binding->Get(v8_str("testExtraShouldCallToRuntime")).As<v8::Function>(); 21645 binding->Get(v8_str("testExtraShouldCallToRuntime")).As<v8::Function>();
21646 result = func->Call(undefined, 0, {}).As<v8::Number>(); 21646 result = func->Call(undefined, 0, {}).As<v8::Number>();
21647 CHECK_EQ(7, result->Int32Value()); 21647 CHECK_EQ(7, result->Int32Value());
21648 } 21648 }
21649 21649
21650 21650
21651 TEST(ExperimentalExtras) {
21652 i::FLAG_experimental_extras = true;
21653
21654 v8::Isolate* isolate = CcTest::isolate();
21655 v8::HandleScope handle_scope(isolate);
21656 LocalContext env;
21657
21658 // standalone.gypi ensures we include the test-experimental-extra.js file,
21659 // which should export the tested functions.
21660 v8::Local<v8::Object> binding = env->GetExtrasBindingObject();
21661
21662 auto func = binding->Get(v8_str("testExperimentalExtraShouldReturnTen"))
21663 .As<v8::Function>();
21664 auto undefined = v8::Undefined(isolate);
21665 auto result = func->Call(undefined, 0, {}).As<v8::Number>();
21666 CHECK_EQ(10, result->Int32Value());
21667
21668 v8::Handle<v8::FunctionTemplate> runtimeFunction =
21669 v8::FunctionTemplate::New(isolate, ExtrasBindingTestRuntimeFunction);
21670 binding->Set(v8_str("runtime"), runtimeFunction->GetFunction());
21671 func = binding->Get(v8_str("testExperimentalExtraShouldCallToRuntime"))
21672 .As<v8::Function>();
21673 result = func->Call(undefined, 0, {}).As<v8::Number>();
21674 CHECK_EQ(7, result->Int32Value());
21675 }
21676
21677
21651 TEST(Map) { 21678 TEST(Map) {
21652 v8::Isolate* isolate = CcTest::isolate(); 21679 v8::Isolate* isolate = CcTest::isolate();
21653 v8::HandleScope handle_scope(isolate); 21680 v8::HandleScope handle_scope(isolate);
21654 LocalContext env; 21681 LocalContext env;
21655 21682
21656 v8::Local<v8::Map> map = v8::Map::New(isolate); 21683 v8::Local<v8::Map> map = v8::Map::New(isolate);
21657 CHECK(map->IsObject()); 21684 CHECK(map->IsObject());
21658 CHECK(map->IsMap()); 21685 CHECK(map->IsMap());
21659 CHECK(map->GetPrototype()->StrictEquals(CompileRun("Map.prototype"))); 21686 CHECK(map->GetPrototype()->StrictEquals(CompileRun("Map.prototype")));
21660 CHECK_EQ(0U, map->Size()); 21687 CHECK_EQ(0U, map->Size());
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
21820 CHECK(try_catch.HasTerminated()); 21847 CHECK(try_catch.HasTerminated());
21821 } 21848 }
21822 21849
21823 21850
21824 TEST(EstimatedContextSize) { 21851 TEST(EstimatedContextSize) {
21825 v8::Isolate* isolate = CcTest::isolate(); 21852 v8::Isolate* isolate = CcTest::isolate();
21826 v8::HandleScope scope(isolate); 21853 v8::HandleScope scope(isolate);
21827 LocalContext env; 21854 LocalContext env;
21828 CHECK(50000 < env->EstimatedSize()); 21855 CHECK(50000 < env->EstimatedSize());
21829 } 21856 }
OLDNEW
« no previous file with comments | « src/snapshot/natives-external.cc ('k') | test/cctest/test-experimental-extra.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698