| 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 21109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21120 v8::Local<v8::Array> entries = map->AsArray(); | 21120 v8::Local<v8::Array> entries = map->AsArray(); |
| 21121 CHECK_EQ(2, entries->Length()); | 21121 CHECK_EQ(2, entries->Length()); |
| 21122 v8::Local<v8::Array> entry = entries->Get(0).As<v8::Array>(); | 21122 v8::Local<v8::Array> entry = entries->Get(0).As<v8::Array>(); |
| 21123 CHECK_EQ(2, entry->Length()); | 21123 CHECK_EQ(2, entry->Length()); |
| 21124 CHECK_EQ(1, entry->Get(0).As<v8::Int32>()->Value()); | 21124 CHECK_EQ(1, entry->Get(0).As<v8::Int32>()->Value()); |
| 21125 CHECK_EQ(2, entry->Get(1).As<v8::Int32>()->Value()); | 21125 CHECK_EQ(2, entry->Get(1).As<v8::Int32>()->Value()); |
| 21126 entry = entries->Get(1).As<v8::Array>(); | 21126 entry = entries->Get(1).As<v8::Array>(); |
| 21127 CHECK_EQ(2, entry->Length()); | 21127 CHECK_EQ(2, entry->Length()); |
| 21128 CHECK_EQ(3, entry->Get(0).As<v8::Int32>()->Value()); | 21128 CHECK_EQ(3, entry->Get(0).As<v8::Int32>()->Value()); |
| 21129 CHECK_EQ(4, entry->Get(1).As<v8::Int32>()->Value()); | 21129 CHECK_EQ(4, entry->Get(1).As<v8::Int32>()->Value()); |
| 21130 |
| 21131 map = v8::Map::FromArray(env.local(), entries).ToLocalChecked(); |
| 21132 CHECK_EQ(2, map->Size()); |
| 21130 } | 21133 } |
| 21131 | 21134 |
| 21132 | 21135 |
| 21133 TEST(Set) { | 21136 TEST(Set) { |
| 21134 v8::Isolate* isolate = CcTest::isolate(); | 21137 v8::Isolate* isolate = CcTest::isolate(); |
| 21135 v8::HandleScope handle_scope(isolate); | 21138 v8::HandleScope handle_scope(isolate); |
| 21136 LocalContext env; | 21139 LocalContext env; |
| 21137 | 21140 |
| 21138 v8::Local<v8::Set> set = v8::Set::New(isolate); | 21141 v8::Local<v8::Set> set = v8::Set::New(isolate); |
| 21139 CHECK(set->IsObject()); | 21142 CHECK(set->IsObject()); |
| 21140 CHECK(set->IsSet()); | 21143 CHECK(set->IsSet()); |
| 21141 CHECK_EQ(0, set->Size()); | 21144 CHECK_EQ(0, set->Size()); |
| 21142 | 21145 |
| 21143 v8::Local<v8::Value> val = CompileRun("new Set([1, 2])"); | 21146 v8::Local<v8::Value> val = CompileRun("new Set([1, 2])"); |
| 21144 CHECK(val->IsSet()); | 21147 CHECK(val->IsSet()); |
| 21145 set = v8::Local<v8::Set>::Cast(val); | 21148 set = v8::Local<v8::Set>::Cast(val); |
| 21146 CHECK_EQ(2, set->Size()); | 21149 CHECK_EQ(2, set->Size()); |
| 21147 | 21150 |
| 21148 v8::Local<v8::Array> keys = set->AsArray(); | 21151 v8::Local<v8::Array> keys = set->AsArray(); |
| 21149 CHECK_EQ(2, keys->Length()); | 21152 CHECK_EQ(2, keys->Length()); |
| 21150 CHECK_EQ(1, keys->Get(0).As<v8::Int32>()->Value()); | 21153 CHECK_EQ(1, keys->Get(0).As<v8::Int32>()->Value()); |
| 21151 CHECK_EQ(2, keys->Get(1).As<v8::Int32>()->Value()); | 21154 CHECK_EQ(2, keys->Get(1).As<v8::Int32>()->Value()); |
| 21155 |
| 21156 set = v8::Set::FromArray(env.local(), keys).ToLocalChecked(); |
| 21157 CHECK_EQ(2, set->Size()); |
| 21152 } | 21158 } |
| OLD | NEW |