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

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

Issue 1236263004: Deprecate unused Map/Set FromArray factory methods (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove calls from cctests Created 5 years, 5 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 | « include/v8.h ('k') | no next file » | 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 21717 matching lines...) Expand 10 before | Expand all | Expand 10 after
21728 map = v8::Local<v8::Map>::Cast(val); 21728 map = v8::Local<v8::Map>::Cast(val);
21729 CHECK_EQ(2U, map->Size()); 21729 CHECK_EQ(2U, map->Size());
21730 21730
21731 v8::Local<v8::Array> contents = map->AsArray(); 21731 v8::Local<v8::Array> contents = map->AsArray();
21732 CHECK_EQ(4U, contents->Length()); 21732 CHECK_EQ(4U, contents->Length());
21733 CHECK_EQ(1, contents->Get(0).As<v8::Int32>()->Value()); 21733 CHECK_EQ(1, contents->Get(0).As<v8::Int32>()->Value());
21734 CHECK_EQ(2, contents->Get(1).As<v8::Int32>()->Value()); 21734 CHECK_EQ(2, contents->Get(1).As<v8::Int32>()->Value());
21735 CHECK_EQ(3, contents->Get(2).As<v8::Int32>()->Value()); 21735 CHECK_EQ(3, contents->Get(2).As<v8::Int32>()->Value());
21736 CHECK_EQ(4, contents->Get(3).As<v8::Int32>()->Value()); 21736 CHECK_EQ(4, contents->Get(3).As<v8::Int32>()->Value());
21737 21737
21738 map = v8::Map::FromArray(env.local(), contents).ToLocalChecked();
21739 CHECK_EQ(2U, map->Size()); 21738 CHECK_EQ(2U, map->Size());
21740 21739
21741 CHECK(map->Has(env.local(), v8::Integer::New(isolate, 1)).FromJust()); 21740 CHECK(map->Has(env.local(), v8::Integer::New(isolate, 1)).FromJust());
21742 CHECK(map->Has(env.local(), v8::Integer::New(isolate, 3)).FromJust()); 21741 CHECK(map->Has(env.local(), v8::Integer::New(isolate, 3)).FromJust());
21743 21742
21744 CHECK(!map->Has(env.local(), v8::Integer::New(isolate, 2)).FromJust()); 21743 CHECK(!map->Has(env.local(), v8::Integer::New(isolate, 2)).FromJust());
21745 CHECK(!map->Has(env.local(), map).FromJust()); 21744 CHECK(!map->Has(env.local(), map).FromJust());
21746 21745
21747 CHECK_EQ(2, map->Get(env.local(), v8::Integer::New(isolate, 1)) 21746 CHECK_EQ(2, map->Get(env.local(), v8::Integer::New(isolate, 1))
21748 .ToLocalChecked() 21747 .ToLocalChecked()
(...skipping 13 matching lines...) Expand all
21762 CHECK(map->Delete(env.local(), map).FromJust()); 21761 CHECK(map->Delete(env.local(), map).FromJust());
21763 CHECK_EQ(2U, map->Size()); 21762 CHECK_EQ(2U, map->Size());
21764 CHECK(!map->Has(env.local(), map).FromJust()); 21763 CHECK(!map->Has(env.local(), map).FromJust());
21765 CHECK(!map->Delete(env.local(), map).FromJust()); 21764 CHECK(!map->Delete(env.local(), map).FromJust());
21766 21765
21767 map->Clear(); 21766 map->Clear();
21768 CHECK_EQ(0U, map->Size()); 21767 CHECK_EQ(0U, map->Size());
21769 } 21768 }
21770 21769
21771 21770
21772 TEST(MapFromArrayOddLength) {
21773 v8::Isolate* isolate = CcTest::isolate();
21774 v8::HandleScope handle_scope(isolate);
21775 LocalContext env;
21776 // Odd lengths result in a null MaybeLocal.
21777 Local<v8::Array> contents = v8::Array::New(isolate, 41);
21778 CHECK(v8::Map::FromArray(env.local(), contents).IsEmpty());
21779 }
21780
21781
21782 TEST(Set) { 21771 TEST(Set) {
21783 v8::Isolate* isolate = CcTest::isolate(); 21772 v8::Isolate* isolate = CcTest::isolate();
21784 v8::HandleScope handle_scope(isolate); 21773 v8::HandleScope handle_scope(isolate);
21785 LocalContext env; 21774 LocalContext env;
21786 21775
21787 v8::Local<v8::Set> set = v8::Set::New(isolate); 21776 v8::Local<v8::Set> set = v8::Set::New(isolate);
21788 CHECK(set->IsObject()); 21777 CHECK(set->IsObject());
21789 CHECK(set->IsSet()); 21778 CHECK(set->IsSet());
21790 CHECK(set->GetPrototype()->StrictEquals(CompileRun("Set.prototype"))); 21779 CHECK(set->GetPrototype()->StrictEquals(CompileRun("Set.prototype")));
21791 CHECK_EQ(0U, set->Size()); 21780 CHECK_EQ(0U, set->Size());
21792 21781
21793 v8::Local<v8::Value> val = CompileRun("new Set([1, 2])"); 21782 v8::Local<v8::Value> val = CompileRun("new Set([1, 2])");
21794 CHECK(val->IsSet()); 21783 CHECK(val->IsSet());
21795 set = v8::Local<v8::Set>::Cast(val); 21784 set = v8::Local<v8::Set>::Cast(val);
21796 CHECK_EQ(2U, set->Size()); 21785 CHECK_EQ(2U, set->Size());
21797 21786
21798 v8::Local<v8::Array> keys = set->AsArray(); 21787 v8::Local<v8::Array> keys = set->AsArray();
21799 CHECK_EQ(2U, keys->Length()); 21788 CHECK_EQ(2U, keys->Length());
21800 CHECK_EQ(1, keys->Get(0).As<v8::Int32>()->Value()); 21789 CHECK_EQ(1, keys->Get(0).As<v8::Int32>()->Value());
21801 CHECK_EQ(2, keys->Get(1).As<v8::Int32>()->Value()); 21790 CHECK_EQ(2, keys->Get(1).As<v8::Int32>()->Value());
21802 21791
21803 set = v8::Set::FromArray(env.local(), keys).ToLocalChecked();
21804 CHECK_EQ(2U, set->Size()); 21792 CHECK_EQ(2U, set->Size());
21805 21793
21806 CHECK(set->Has(env.local(), v8::Integer::New(isolate, 1)).FromJust()); 21794 CHECK(set->Has(env.local(), v8::Integer::New(isolate, 1)).FromJust());
21807 CHECK(set->Has(env.local(), v8::Integer::New(isolate, 2)).FromJust()); 21795 CHECK(set->Has(env.local(), v8::Integer::New(isolate, 2)).FromJust());
21808 21796
21809 CHECK(!set->Has(env.local(), v8::Integer::New(isolate, 3)).FromJust()); 21797 CHECK(!set->Has(env.local(), v8::Integer::New(isolate, 3)).FromJust());
21810 CHECK(!set->Has(env.local(), set).FromJust()); 21798 CHECK(!set->Has(env.local(), set).FromJust());
21811 21799
21812 CHECK(!set->Add(env.local(), set).IsEmpty()); 21800 CHECK(!set->Add(env.local(), set).IsEmpty());
21813 CHECK_EQ(3U, set->Size()); 21801 CHECK_EQ(3U, set->Size());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
21853 " fake.age;\n" 21841 " fake.age;\n"
21854 " result = 1;\n" 21842 " result = 1;\n"
21855 " } catch (e) {\n" 21843 " } catch (e) {\n"
21856 " }\n" 21844 " }\n"
21857 " test(d+1);\n" 21845 " test(d+1);\n"
21858 "}\n" 21846 "}\n"
21859 "test(0);\n" 21847 "test(0);\n"
21860 "result;\n", 21848 "result;\n",
21861 0); 21849 0);
21862 } 21850 }
OLDNEW
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698