* in the same manner as the array returned from AsArray().
* Guaranteed to be side-effect free if the array contains no holes.
*/
- static V8_WARN_UNUSED_RESULT MaybeLocal<Map> FromArray(Local<Context> context,
- Local<Array> array);
+ static V8_WARN_UNUSED_RESULT V8_DEPRECATED(
+ "Use mutation methods instead",
+ MaybeLocal<Map> FromArray(Local<Context> context, Local<Array> array));
V8_INLINE static Map* Cast(Value* obj);
* Creates a new Set containing the items in array.
* Guaranteed to be side-effect free if the array contains no holes.
*/
- static V8_WARN_UNUSED_RESULT MaybeLocal<Set> FromArray(Local<Context> context,
- Local<Array> array);
+ static V8_WARN_UNUSED_RESULT V8_DEPRECATED(
+ "Use mutation methods instead",
+ MaybeLocal<Set> FromArray(Local<Context> context, Local<Array> array));
V8_INLINE static Set* Cast(Value* obj);
CHECK_EQ(3, contents->Get(2).As<v8::Int32>()->Value());
CHECK_EQ(4, contents->Get(3).As<v8::Int32>()->Value());
- map = v8::Map::FromArray(env.local(), contents).ToLocalChecked();
CHECK_EQ(2U, map->Size());
CHECK(map->Has(env.local(), v8::Integer::New(isolate, 1)).FromJust());
}
-TEST(MapFromArrayOddLength) {
- v8::Isolate* isolate = CcTest::isolate();
- v8::HandleScope handle_scope(isolate);
- LocalContext env;
- // Odd lengths result in a null MaybeLocal.
- Local<v8::Array> contents = v8::Array::New(isolate, 41);
- CHECK(v8::Map::FromArray(env.local(), contents).IsEmpty());
-}
-
-
TEST(Set) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
CHECK_EQ(1, keys->Get(0).As<v8::Int32>()->Value());
CHECK_EQ(2, keys->Get(1).As<v8::Int32>()->Value());
- set = v8::Set::FromArray(env.local(), keys).ToLocalChecked();
CHECK_EQ(2U, set->Size());
CHECK(set->Has(env.local(), v8::Integer::New(isolate, 1)).FromJust());