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 24606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24617 set->Clear(); | 24617 set->Clear(); |
24618 CHECK_EQ(0U, set->Size()); | 24618 CHECK_EQ(0U, set->Size()); |
24619 } | 24619 } |
24620 | 24620 |
24621 TEST(SetDeleteThenAsArray) { | 24621 TEST(SetDeleteThenAsArray) { |
24622 // https://bugs.chromium.org/p/v8/issues/detail?id=4946 | 24622 // https://bugs.chromium.org/p/v8/issues/detail?id=4946 |
24623 v8::Isolate* isolate = CcTest::isolate(); | 24623 v8::Isolate* isolate = CcTest::isolate(); |
24624 v8::HandleScope handle_scope(isolate); | 24624 v8::HandleScope handle_scope(isolate); |
24625 LocalContext env; | 24625 LocalContext env; |
24626 | 24626 |
24627 // make an array | 24627 // make a Set |
24628 v8::Local<v8::Value> val = CompileRun("new Set([1, 2, 3])"); | 24628 v8::Local<v8::Value> val = CompileRun("new Set([1, 2, 3])"); |
24629 v8::Local<v8::Set> set = v8::Local<v8::Set>::Cast(val); | 24629 v8::Local<v8::Set> set = v8::Local<v8::Set>::Cast(val); |
24630 CHECK_EQ(3U, set->Size()); | 24630 CHECK_EQ(3U, set->Size()); |
24631 | 24631 |
24632 // delete the "middle" element (using AsArray to | 24632 // delete the "middle" element (using AsArray to |
24633 // determine which element is the "middle" element) | 24633 // determine which element is the "middle" element) |
24634 v8::Local<v8::Array> array1 = set->AsArray(); | 24634 v8::Local<v8::Array> array1 = set->AsArray(); |
24635 CHECK_EQ(3U, array1->Length()); | 24635 CHECK_EQ(3U, array1->Length()); |
24636 CHECK(set->Delete(env.local(), array1->Get(env.local(), 1).ToLocalChecked()) | 24636 CHECK(set->Delete(env.local(), array1->Get(env.local(), 1).ToLocalChecked()) |
24637 .FromJust()); | 24637 .FromJust()); |
24638 | 24638 |
24639 // make sure there are no undefined values when we convert to an array again. | 24639 // make sure there are no undefined values when we convert to an array again. |
24640 v8::Local<v8::Array> array2 = set->AsArray(); | 24640 v8::Local<v8::Array> array2 = set->AsArray(); |
24641 uint32_t length = array2->Length(); | 24641 uint32_t length = array2->Length(); |
24642 CHECK_EQ(2U, length); | 24642 CHECK_EQ(2U, length); |
24643 for (uint32_t i = 0; i < length; i++) { | 24643 for (uint32_t i = 0; i < length; i++) { |
24644 CHECK(!array2->Get(env.local(), i).ToLocalChecked()->IsUndefined()); | 24644 CHECK(!array2->Get(env.local(), i).ToLocalChecked()->IsUndefined()); |
24645 } | 24645 } |
24646 } | 24646 } |
24647 | 24647 |
| 24648 TEST(MapDeleteThenAsArray) { |
| 24649 // https://bugs.chromium.org/p/v8/issues/detail?id=4946 |
| 24650 v8::Isolate* isolate = CcTest::isolate(); |
| 24651 v8::HandleScope handle_scope(isolate); |
| 24652 LocalContext env; |
| 24653 |
| 24654 // make a Map |
| 24655 v8::Local<v8::Value> val = CompileRun("new Map([[1, 2], [3, 4], [5, 6]])"); |
| 24656 v8::Local<v8::Map> map = v8::Local<v8::Map>::Cast(val); |
| 24657 CHECK_EQ(3U, map->Size()); |
| 24658 |
| 24659 // delete the "middle" element (using AsArray to |
| 24660 // determine which element is the "middle" element) |
| 24661 v8::Local<v8::Array> array1 = map->AsArray(); |
| 24662 CHECK_EQ(6U, array1->Length()); |
| 24663 // Map::AsArray returns a flat array, so the second key is at index 2. |
| 24664 v8::Local<v8::Value> key = array1->Get(env.local(), 2).ToLocalChecked(); |
| 24665 CHECK(map->Delete(env.local(), key).FromJust()); |
| 24666 |
| 24667 // make sure there are no undefined values when we convert to an array again. |
| 24668 v8::Local<v8::Array> array2 = map->AsArray(); |
| 24669 uint32_t length = array2->Length(); |
| 24670 CHECK_EQ(4U, length); |
| 24671 for (uint32_t i = 0; i < length; i++) { |
| 24672 CHECK(!array2->Get(env.local(), i).ToLocalChecked()->IsUndefined()); |
| 24673 } |
| 24674 } |
| 24675 |
24648 TEST(CompatibleReceiverCheckOnCachedICHandler) { | 24676 TEST(CompatibleReceiverCheckOnCachedICHandler) { |
24649 v8::Isolate* isolate = CcTest::isolate(); | 24677 v8::Isolate* isolate = CcTest::isolate(); |
24650 v8::HandleScope scope(isolate); | 24678 v8::HandleScope scope(isolate); |
24651 v8::Local<v8::FunctionTemplate> parent = FunctionTemplate::New(isolate); | 24679 v8::Local<v8::FunctionTemplate> parent = FunctionTemplate::New(isolate); |
24652 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, parent); | 24680 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, parent); |
24653 auto returns_42 = | 24681 auto returns_42 = |
24654 v8::FunctionTemplate::New(isolate, Returns42, Local<Value>(), signature); | 24682 v8::FunctionTemplate::New(isolate, Returns42, Local<Value>(), signature); |
24655 parent->PrototypeTemplate()->SetAccessorProperty(v8_str("age"), returns_42); | 24683 parent->PrototypeTemplate()->SetAccessorProperty(v8_str("age"), returns_42); |
24656 v8::Local<v8::FunctionTemplate> child = v8::FunctionTemplate::New(isolate); | 24684 v8::Local<v8::FunctionTemplate> child = v8::FunctionTemplate::New(isolate); |
24657 child->Inherit(parent); | 24685 child->Inherit(parent); |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
25033 } | 25061 } |
25034 | 25062 |
25035 TEST(PrivateForApiIsNumber) { | 25063 TEST(PrivateForApiIsNumber) { |
25036 LocalContext context; | 25064 LocalContext context; |
25037 v8::Isolate* isolate = CcTest::isolate(); | 25065 v8::Isolate* isolate = CcTest::isolate(); |
25038 v8::HandleScope scope(isolate); | 25066 v8::HandleScope scope(isolate); |
25039 | 25067 |
25040 // Shouldn't crash. | 25068 // Shouldn't crash. |
25041 v8::Private::ForApi(isolate, v8_str("42")); | 25069 v8::Private::ForApi(isolate, v8_str("42")); |
25042 } | 25070 } |
OLD | NEW |