OLD | NEW |
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 21358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21369 | 21369 |
21370 | 21370 |
21371 TEST(Map) { | 21371 TEST(Map) { |
21372 v8::Isolate* isolate = CcTest::isolate(); | 21372 v8::Isolate* isolate = CcTest::isolate(); |
21373 v8::HandleScope handle_scope(isolate); | 21373 v8::HandleScope handle_scope(isolate); |
21374 LocalContext env; | 21374 LocalContext env; |
21375 | 21375 |
21376 v8::Local<v8::Map> map = v8::Map::New(isolate); | 21376 v8::Local<v8::Map> map = v8::Map::New(isolate); |
21377 CHECK(map->IsObject()); | 21377 CHECK(map->IsObject()); |
21378 CHECK(map->IsMap()); | 21378 CHECK(map->IsMap()); |
| 21379 CHECK(map->GetPrototype()->StrictEquals(CompileRun("Map.prototype"))); |
21379 CHECK_EQ(0, map->Size()); | 21380 CHECK_EQ(0, map->Size()); |
21380 | 21381 |
21381 v8::Local<v8::Value> val = CompileRun("new Map([[1, 2], [3, 4]])"); | 21382 v8::Local<v8::Value> val = CompileRun("new Map([[1, 2], [3, 4]])"); |
21382 CHECK(val->IsMap()); | 21383 CHECK(val->IsMap()); |
21383 map = v8::Local<v8::Map>::Cast(val); | 21384 map = v8::Local<v8::Map>::Cast(val); |
21384 CHECK_EQ(2, map->Size()); | 21385 CHECK_EQ(2, map->Size()); |
21385 | 21386 |
21386 v8::Local<v8::Array> entries = map->AsArray(); | 21387 v8::Local<v8::Array> entries = map->AsArray(); |
21387 CHECK_EQ(2, entries->Length()); | 21388 CHECK_EQ(2, entries->Length()); |
21388 v8::Local<v8::Array> entry = entries->Get(0).As<v8::Array>(); | 21389 v8::Local<v8::Array> entry = entries->Get(0).As<v8::Array>(); |
(...skipping 11 matching lines...) Expand all Loading... |
21400 | 21401 |
21401 | 21402 |
21402 TEST(Set) { | 21403 TEST(Set) { |
21403 v8::Isolate* isolate = CcTest::isolate(); | 21404 v8::Isolate* isolate = CcTest::isolate(); |
21404 v8::HandleScope handle_scope(isolate); | 21405 v8::HandleScope handle_scope(isolate); |
21405 LocalContext env; | 21406 LocalContext env; |
21406 | 21407 |
21407 v8::Local<v8::Set> set = v8::Set::New(isolate); | 21408 v8::Local<v8::Set> set = v8::Set::New(isolate); |
21408 CHECK(set->IsObject()); | 21409 CHECK(set->IsObject()); |
21409 CHECK(set->IsSet()); | 21410 CHECK(set->IsSet()); |
| 21411 CHECK(set->GetPrototype()->StrictEquals(CompileRun("Set.prototype"))); |
21410 CHECK_EQ(0, set->Size()); | 21412 CHECK_EQ(0, set->Size()); |
21411 | 21413 |
21412 v8::Local<v8::Value> val = CompileRun("new Set([1, 2])"); | 21414 v8::Local<v8::Value> val = CompileRun("new Set([1, 2])"); |
21413 CHECK(val->IsSet()); | 21415 CHECK(val->IsSet()); |
21414 set = v8::Local<v8::Set>::Cast(val); | 21416 set = v8::Local<v8::Set>::Cast(val); |
21415 CHECK_EQ(2, set->Size()); | 21417 CHECK_EQ(2, set->Size()); |
21416 | 21418 |
21417 v8::Local<v8::Array> keys = set->AsArray(); | 21419 v8::Local<v8::Array> keys = set->AsArray(); |
21418 CHECK_EQ(2, keys->Length()); | 21420 CHECK_EQ(2, keys->Length()); |
21419 CHECK_EQ(1, keys->Get(0).As<v8::Int32>()->Value()); | 21421 CHECK_EQ(1, keys->Get(0).As<v8::Int32>()->Value()); |
21420 CHECK_EQ(2, keys->Get(1).As<v8::Int32>()->Value()); | 21422 CHECK_EQ(2, keys->Get(1).As<v8::Int32>()->Value()); |
21421 | 21423 |
21422 set = v8::Set::FromArray(env.local(), keys).ToLocalChecked(); | 21424 set = v8::Set::FromArray(env.local(), keys).ToLocalChecked(); |
21423 CHECK_EQ(2, set->Size()); | 21425 CHECK_EQ(2, set->Size()); |
21424 } | 21426 } |
OLD | NEW |