Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(667)

Side by Side Diff: test/cctest/test-declarative-accessors.cc

Issue 101763003: Replace 'operator*' with explicit 'get' method on SmartPointer (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Reupload to make rietveld happy Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-debug.cc ('k') | test/cctest/test-func-name-inference.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 v8::HandleScope handle_scope(helper->isolate_); 170 v8::HandleScope handle_scope(helper->isolate_);
171 int index = 17; 171 int index = 17;
172 int internal_field = 6; 172 int internal_field = 6;
173 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = 173 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
174 OOD::NewInternalFieldDereference(helper->isolate_, internal_field) 174 OOD::NewInternalFieldDereference(helper->isolate_, internal_field)
175 ->NewRawShift(helper->isolate_, static_cast<uint16_t>(index*sizeof(T))) 175 ->NewRawShift(helper->isolate_, static_cast<uint16_t>(index*sizeof(T)))
176 ->NewPrimitiveValue(helper->isolate_, data_type, 0); 176 ->NewPrimitiveValue(helper->isolate_, data_type, 0);
177 v8::Handle<v8::Value> expected = Convert(value, helper->isolate_); 177 v8::Handle<v8::Value> expected = Convert(value, helper->isolate_);
178 helper->array_->Reset(); 178 helper->array_->Reset();
179 helper->array_->As<T*>()[index] = value; 179 helper->array_->As<T*>()[index] = value;
180 VerifyRead(descriptor, internal_field, *helper->array_, expected); 180 VerifyRead(descriptor, internal_field, helper->array_.get(), expected);
181 } 181 }
182 182
183 183
184 TEST(PrimitiveValueRead) { 184 TEST(PrimitiveValueRead) {
185 DescriptorTestHelper helper; 185 DescriptorTestHelper helper;
186 TestPrimitiveValue<int32_t>(203, v8::kDescriptorInt32Type, &helper); 186 TestPrimitiveValue<int32_t>(203, v8::kDescriptorInt32Type, &helper);
187 TestPrimitiveValue<float>(23.7f, v8::kDescriptorFloatType, &helper); 187 TestPrimitiveValue<float>(23.7f, v8::kDescriptorFloatType, &helper);
188 TestPrimitiveValue<double>(23.7, v8::kDescriptorDoubleType, &helper); 188 TestPrimitiveValue<double>(23.7, v8::kDescriptorDoubleType, &helper);
189 } 189 }
190 190
(...skipping 25 matching lines...) Expand all
216 case 4: 216 case 4:
217 descriptor = raw_descriptor->NewBitmaskCompare32( 217 descriptor = raw_descriptor->NewBitmaskCompare32(
218 helper->isolate_, 218 helper->isolate_,
219 static_cast<uint32_t>(bitmask), 219 static_cast<uint32_t>(bitmask),
220 static_cast<uint32_t>(compare_value)); 220 static_cast<uint32_t>(compare_value));
221 break; 221 break;
222 default: 222 default:
223 CHECK(false); 223 CHECK(false);
224 break; 224 break;
225 } 225 }
226 AlignedArray* array = *helper->array_; 226 AlignedArray* array = helper->array_.get();
227 array->Reset(); 227 array->Reset();
228 VerifyRead(descriptor, internal_field, array, v8::False(helper->isolate_)); 228 VerifyRead(descriptor, internal_field, array, v8::False(helper->isolate_));
229 array->As<T*>()[index] = compare_value; 229 array->As<T*>()[index] = compare_value;
230 VerifyRead(descriptor, internal_field, array, v8::True(helper->isolate_)); 230 VerifyRead(descriptor, internal_field, array, v8::True(helper->isolate_));
231 helper->array_->As<T*>()[index] = compare_value & bitmask; 231 helper->array_->As<T*>()[index] = compare_value & bitmask;
232 VerifyRead(descriptor, internal_field, array, v8::True(helper->isolate_)); 232 VerifyRead(descriptor, internal_field, array, v8::True(helper->isolate_));
233 } 233 }
234 234
235 235
236 TEST(BitmaskCompareRead) { 236 TEST(BitmaskCompareRead) {
237 DescriptorTestHelper helper; 237 DescriptorTestHelper helper;
238 TestBitmaskCompare<uint8_t>(0xf3, 0xa8, &helper); 238 TestBitmaskCompare<uint8_t>(0xf3, 0xa8, &helper);
239 TestBitmaskCompare<uint16_t>(0xfefe, 0x7d42, &helper); 239 TestBitmaskCompare<uint16_t>(0xfefe, 0x7d42, &helper);
240 TestBitmaskCompare<uint32_t>(0xfefeab18, 0x1234fdec, &helper); 240 TestBitmaskCompare<uint32_t>(0xfefeab18, 0x1234fdec, &helper);
241 } 241 }
242 242
243 243
244 TEST(PointerCompareRead) { 244 TEST(PointerCompareRead) {
245 DescriptorTestHelper helper; 245 DescriptorTestHelper helper;
246 v8::HandleScope handle_scope(helper.isolate_); 246 v8::HandleScope handle_scope(helper.isolate_);
247 int index = 35; 247 int index = 35;
248 int internal_field = 3; 248 int internal_field = 3;
249 void* ptr = helper.isolate_; 249 void* ptr = helper.isolate_;
250 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = 250 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
251 OOD::NewInternalFieldDereference(helper.isolate_, internal_field) 251 OOD::NewInternalFieldDereference(helper.isolate_, internal_field)
252 ->NewRawShift(helper.isolate_, static_cast<uint16_t>(index*sizeof(ptr))) 252 ->NewRawShift(helper.isolate_, static_cast<uint16_t>(index*sizeof(ptr)))
253 ->NewPointerCompare(helper.isolate_, ptr); 253 ->NewPointerCompare(helper.isolate_, ptr);
254 AlignedArray* array = *helper.array_; 254 AlignedArray* array = helper.array_.get();
255 VerifyRead(descriptor, internal_field, array, v8::False(helper.isolate_)); 255 VerifyRead(descriptor, internal_field, array, v8::False(helper.isolate_));
256 array->As<uintptr_t*>()[index] = reinterpret_cast<uintptr_t>(ptr); 256 array->As<uintptr_t*>()[index] = reinterpret_cast<uintptr_t>(ptr);
257 VerifyRead(descriptor, internal_field, array, v8::True(helper.isolate_)); 257 VerifyRead(descriptor, internal_field, array, v8::True(helper.isolate_));
258 } 258 }
259 259
260 260
261 TEST(PointerDereferenceRead) { 261 TEST(PointerDereferenceRead) {
262 DescriptorTestHelper helper; 262 DescriptorTestHelper helper;
263 v8::HandleScope handle_scope(helper.isolate_); 263 v8::HandleScope handle_scope(helper.isolate_);
264 int first_index = 13; 264 int first_index = 13;
265 int internal_field = 7; 265 int internal_field = 7;
266 int second_index = 11; 266 int second_index = 11;
267 int pointed_to_index = 75; 267 int pointed_to_index = 75;
268 uint16_t expected = 0x1425; 268 uint16_t expected = 0x1425;
269 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = 269 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
270 OOD::NewInternalFieldDereference(helper.isolate_, internal_field) 270 OOD::NewInternalFieldDereference(helper.isolate_, internal_field)
271 ->NewRawShift(helper.isolate_, first_index*kPointerSize) 271 ->NewRawShift(helper.isolate_, first_index*kPointerSize)
272 ->NewRawDereference(helper.isolate_) 272 ->NewRawDereference(helper.isolate_)
273 ->NewRawShift(helper.isolate_, 273 ->NewRawShift(helper.isolate_,
274 static_cast<uint16_t>(second_index*sizeof(int16_t))) 274 static_cast<uint16_t>(second_index*sizeof(int16_t)))
275 ->NewPrimitiveValue(helper.isolate_, v8::kDescriptorInt16Type, 0); 275 ->NewPrimitiveValue(helper.isolate_, v8::kDescriptorInt16Type, 0);
276 AlignedArray* array = *helper.array_; 276 AlignedArray* array = helper.array_.get();
277 array->As<uintptr_t**>()[first_index] = 277 array->As<uintptr_t**>()[first_index] =
278 &array->As<uintptr_t*>()[pointed_to_index]; 278 &array->As<uintptr_t*>()[pointed_to_index];
279 VerifyRead(descriptor, internal_field, array, v8::Integer::New(0)); 279 VerifyRead(descriptor, internal_field, array, v8::Integer::New(0));
280 second_index += pointed_to_index*sizeof(uintptr_t)/sizeof(uint16_t); 280 second_index += pointed_to_index*sizeof(uintptr_t)/sizeof(uint16_t);
281 array->As<uint16_t*>()[second_index] = expected; 281 array->As<uint16_t*>()[second_index] = expected;
282 VerifyRead(descriptor, internal_field, array, v8::Integer::New(expected)); 282 VerifyRead(descriptor, internal_field, array, v8::Integer::New(expected));
283 } 283 }
284 284
285 285
286 TEST(HandleDereferenceRead) { 286 TEST(HandleDereferenceRead) {
287 DescriptorTestHelper helper; 287 DescriptorTestHelper helper;
288 v8::HandleScope handle_scope(helper.isolate_); 288 v8::HandleScope handle_scope(helper.isolate_);
289 int index = 13; 289 int index = 13;
290 int internal_field = 0; 290 int internal_field = 0;
291 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = 291 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
292 OOD::NewInternalFieldDereference(helper.isolate_, internal_field) 292 OOD::NewInternalFieldDereference(helper.isolate_, internal_field)
293 ->NewRawShift(helper.isolate_, index*kPointerSize) 293 ->NewRawShift(helper.isolate_, index*kPointerSize)
294 ->NewHandleDereference(helper.isolate_); 294 ->NewHandleDereference(helper.isolate_);
295 HandleArray* array = *helper.handle_array_; 295 HandleArray* array = helper.handle_array_.get();
296 v8::Handle<v8::String> expected = v8_str("whatever"); 296 v8::Handle<v8::String> expected = v8_str("whatever");
297 array->handles_[index].Reset(helper.isolate_, expected); 297 array->handles_[index].Reset(helper.isolate_, expected);
298 VerifyRead(descriptor, internal_field, array, expected); 298 VerifyRead(descriptor, internal_field, array, expected);
299 } 299 }
OLDNEW
« no previous file with comments | « test/cctest/test-debug.cc ('k') | test/cctest/test-func-name-inference.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698