OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 20 matching lines...) Expand all Loading... |
31 | 31 |
32 #include "src/factory.h" | 32 #include "src/factory.h" |
33 #include "test/cctest/cctest.h" | 33 #include "test/cctest/cctest.h" |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 using namespace v8::internal; | 37 using namespace v8::internal; |
38 | 38 |
39 | 39 |
40 TEST(Set) { | 40 TEST(Set) { |
41 i::FLAG_harmony_collections = true; | |
42 | |
43 LocalContext context; | 41 LocalContext context; |
44 Isolate* isolate = CcTest::i_isolate(); | 42 Isolate* isolate = CcTest::i_isolate(); |
45 Factory* factory = isolate->factory(); | 43 Factory* factory = isolate->factory(); |
46 HandleScope scope(isolate); | 44 HandleScope scope(isolate); |
47 Handle<OrderedHashSet> ordered_set = factory->NewOrderedHashSet(); | 45 Handle<OrderedHashSet> ordered_set = factory->NewOrderedHashSet(); |
48 CHECK_EQ(2, ordered_set->NumberOfBuckets()); | 46 CHECK_EQ(2, ordered_set->NumberOfBuckets()); |
49 CHECK_EQ(0, ordered_set->NumberOfElements()); | 47 CHECK_EQ(0, ordered_set->NumberOfElements()); |
50 CHECK_EQ(0, ordered_set->NumberOfDeletedElements()); | 48 CHECK_EQ(0, ordered_set->NumberOfDeletedElements()); |
51 | 49 |
52 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 50 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 ordered_set = OrderedHashSet::Remove(ordered_set, obj2, &was_present); | 96 ordered_set = OrderedHashSet::Remove(ordered_set, obj2, &was_present); |
99 CHECK(was_present); | 97 CHECK(was_present); |
100 ordered_set = OrderedHashSet::Remove(ordered_set, obj3, &was_present); | 98 ordered_set = OrderedHashSet::Remove(ordered_set, obj3, &was_present); |
101 CHECK(was_present); | 99 CHECK(was_present); |
102 CHECK_EQ(1, ordered_set->NumberOfElements()); | 100 CHECK_EQ(1, ordered_set->NumberOfElements()); |
103 CHECK_EQ(2, ordered_set->NumberOfBuckets()); | 101 CHECK_EQ(2, ordered_set->NumberOfBuckets()); |
104 } | 102 } |
105 | 103 |
106 | 104 |
107 TEST(Map) { | 105 TEST(Map) { |
108 i::FLAG_harmony_collections = true; | |
109 | |
110 LocalContext context; | 106 LocalContext context; |
111 Isolate* isolate = CcTest::i_isolate(); | 107 Isolate* isolate = CcTest::i_isolate(); |
112 Factory* factory = isolate->factory(); | 108 Factory* factory = isolate->factory(); |
113 HandleScope scope(isolate); | 109 HandleScope scope(isolate); |
114 Handle<OrderedHashMap> ordered_map = factory->NewOrderedHashMap(); | 110 Handle<OrderedHashMap> ordered_map = factory->NewOrderedHashMap(); |
115 CHECK_EQ(2, ordered_map->NumberOfBuckets()); | 111 CHECK_EQ(2, ordered_map->NumberOfBuckets()); |
116 CHECK_EQ(0, ordered_map->NumberOfElements()); | 112 CHECK_EQ(0, ordered_map->NumberOfElements()); |
117 CHECK_EQ(0, ordered_map->NumberOfDeletedElements()); | 113 CHECK_EQ(0, ordered_map->NumberOfDeletedElements()); |
118 | 114 |
119 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 115 Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 ordered_map = OrderedHashMap::Remove(ordered_map, obj2, &was_present); | 161 ordered_map = OrderedHashMap::Remove(ordered_map, obj2, &was_present); |
166 CHECK(was_present); | 162 CHECK(was_present); |
167 ordered_map = OrderedHashMap::Remove(ordered_map, obj3, &was_present); | 163 ordered_map = OrderedHashMap::Remove(ordered_map, obj3, &was_present); |
168 CHECK(was_present); | 164 CHECK(was_present); |
169 CHECK_EQ(1, ordered_map->NumberOfElements()); | 165 CHECK_EQ(1, ordered_map->NumberOfElements()); |
170 CHECK_EQ(2, ordered_map->NumberOfBuckets()); | 166 CHECK_EQ(2, ordered_map->NumberOfBuckets()); |
171 } | 167 } |
172 | 168 |
173 | 169 |
174 } | 170 } |
OLD | NEW |