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

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

Issue 12425012: fix more windows warnings (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: whoops Created 7 years, 9 months 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 | « no previous file | no next file » | 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 template<typename T> 166 template<typename T>
167 static void TestPrimitiveValue( 167 static void TestPrimitiveValue(
168 T value, 168 T value,
169 v8::DeclaredAccessorDescriptorDataType data_type, 169 v8::DeclaredAccessorDescriptorDataType data_type,
170 DescriptorTestHelper* helper) { 170 DescriptorTestHelper* helper) {
171 v8::HandleScope handle_scope; 171 v8::HandleScope handle_scope;
172 int index = 17; 172 int index = 17;
173 int internal_field = 6; 173 int internal_field = 6;
174 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = 174 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
175 OOD::NewInternalFieldDereference(helper->isolate_, internal_field) 175 OOD::NewInternalFieldDereference(helper->isolate_, internal_field)
176 ->NewRawShift(helper->isolate_, index*sizeof(T)) 176 ->NewRawShift(helper->isolate_, static_cast<uint16_t>(index*sizeof(T)))
177 ->NewPrimitiveValue(helper->isolate_, data_type, 0); 177 ->NewPrimitiveValue(helper->isolate_, data_type, 0);
178 v8::Handle<v8::Value> expected = Convert(value, helper->isolate_); 178 v8::Handle<v8::Value> expected = Convert(value, helper->isolate_);
179 helper->array_->Reset(); 179 helper->array_->Reset();
180 helper->array_->As<T*>()[index] = value; 180 helper->array_->As<T*>()[index] = value;
181 VerifyRead(descriptor, internal_field, *helper->array_, expected); 181 VerifyRead(descriptor, internal_field, *helper->array_, expected);
182 } 182 }
183 183
184 184
185 TEST(PrimitiveValueRead) { 185 TEST(PrimitiveValueRead) {
186 DescriptorTestHelper helper; 186 DescriptorTestHelper helper;
187 TestPrimitiveValue<int32_t>(203, v8::kDescriptorInt32Type, &helper); 187 TestPrimitiveValue<int32_t>(203, v8::kDescriptorInt32Type, &helper);
188 TestPrimitiveValue<float>(23.7f, v8::kDescriptorFloatType, &helper); 188 TestPrimitiveValue<float>(23.7f, v8::kDescriptorFloatType, &helper);
189 TestPrimitiveValue<double>(23.7, v8::kDescriptorDoubleType, &helper); 189 TestPrimitiveValue<double>(23.7, v8::kDescriptorDoubleType, &helper);
190 } 190 }
191 191
192 192
193 template<typename T> 193 template<typename T>
194 static void TestBitmaskCompare(T bitmask, 194 static void TestBitmaskCompare(T bitmask,
195 T compare_value, 195 T compare_value,
196 DescriptorTestHelper* helper) { 196 DescriptorTestHelper* helper) {
197 v8::HandleScope handle_scope; 197 v8::HandleScope handle_scope;
198 int index = 13; 198 int index = 13;
199 int internal_field = 4; 199 int internal_field = 4;
200 v8::Handle<v8::RawOperationDescriptor> raw_descriptor = 200 v8::Handle<v8::RawOperationDescriptor> raw_descriptor =
201 OOD::NewInternalFieldDereference(helper->isolate_, internal_field) 201 OOD::NewInternalFieldDereference(helper->isolate_, internal_field)
202 ->NewRawShift(helper->isolate_, index*sizeof(T)); 202 ->NewRawShift(helper->isolate_, static_cast<uint16_t>(index*sizeof(T)));
203 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor; 203 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor;
204 switch (sizeof(T)) { 204 switch (sizeof(T)) {
205 case 1: 205 case 1:
206 descriptor = raw_descriptor->NewBitmaskCompare8( 206 descriptor = raw_descriptor->NewBitmaskCompare8(
207 helper->isolate_, 207 helper->isolate_,
208 static_cast<uint8_t>(bitmask), 208 static_cast<uint8_t>(bitmask),
209 static_cast<uint8_t>(compare_value)); 209 static_cast<uint8_t>(compare_value));
210 break; 210 break;
211 case 2: 211 case 2:
212 descriptor = raw_descriptor->NewBitmaskCompare16( 212 descriptor = raw_descriptor->NewBitmaskCompare16(
(...skipping 30 matching lines...) Expand all
243 243
244 244
245 TEST(PointerCompareRead) { 245 TEST(PointerCompareRead) {
246 DescriptorTestHelper helper; 246 DescriptorTestHelper helper;
247 v8::HandleScope handle_scope; 247 v8::HandleScope handle_scope;
248 int index = 35; 248 int index = 35;
249 int internal_field = 3; 249 int internal_field = 3;
250 void* ptr = helper.isolate_; 250 void* ptr = helper.isolate_;
251 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = 251 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
252 OOD::NewInternalFieldDereference(helper.isolate_, internal_field) 252 OOD::NewInternalFieldDereference(helper.isolate_, internal_field)
253 ->NewRawShift(helper.isolate_, index*sizeof(ptr)) 253 ->NewRawShift(helper.isolate_, static_cast<uint16_t>(index*sizeof(ptr)))
254 ->NewPointerCompare(helper.isolate_, ptr); 254 ->NewPointerCompare(helper.isolate_, ptr);
255 AlignedArray* array = *helper.array_; 255 AlignedArray* array = *helper.array_;
256 VerifyRead(descriptor, internal_field, array, v8::False(helper.isolate_)); 256 VerifyRead(descriptor, internal_field, array, v8::False(helper.isolate_));
257 array->As<uintptr_t*>()[index] = reinterpret_cast<uintptr_t>(ptr); 257 array->As<uintptr_t*>()[index] = reinterpret_cast<uintptr_t>(ptr);
258 VerifyRead(descriptor, internal_field, array, v8::True(helper.isolate_)); 258 VerifyRead(descriptor, internal_field, array, v8::True(helper.isolate_));
259 } 259 }
260 260
261 261
262 TEST(PointerDereferenceRead) { 262 TEST(PointerDereferenceRead) {
263 DescriptorTestHelper helper; 263 DescriptorTestHelper helper;
264 v8::HandleScope handle_scope; 264 v8::HandleScope handle_scope;
265 int first_index = 13; 265 int first_index = 13;
266 int internal_field = 7; 266 int internal_field = 7;
267 int second_index = 11; 267 int second_index = 11;
268 int pointed_to_index = 75; 268 int pointed_to_index = 75;
269 uint16_t expected = 0x1425; 269 uint16_t expected = 0x1425;
270 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = 270 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
271 OOD::NewInternalFieldDereference(helper.isolate_, internal_field) 271 OOD::NewInternalFieldDereference(helper.isolate_, internal_field)
272 ->NewRawShift(helper.isolate_, first_index*kPointerSize) 272 ->NewRawShift(helper.isolate_, first_index*kPointerSize)
273 ->NewRawDereference(helper.isolate_) 273 ->NewRawDereference(helper.isolate_)
274 ->NewRawShift(helper.isolate_, second_index*sizeof(int16_t)) 274 ->NewRawShift(helper.isolate_,
275 static_cast<uint16_t>(second_index*sizeof(int16_t)))
275 ->NewPrimitiveValue(helper.isolate_, v8::kDescriptorInt16Type, 0); 276 ->NewPrimitiveValue(helper.isolate_, v8::kDescriptorInt16Type, 0);
276 AlignedArray* array = *helper.array_; 277 AlignedArray* array = *helper.array_;
277 array->As<uintptr_t**>()[first_index] = 278 array->As<uintptr_t**>()[first_index] =
278 &array->As<uintptr_t*>()[pointed_to_index]; 279 &array->As<uintptr_t*>()[pointed_to_index];
279 VerifyRead(descriptor, internal_field, array, v8::Integer::New(0)); 280 VerifyRead(descriptor, internal_field, array, v8::Integer::New(0));
280 second_index += pointed_to_index*sizeof(uintptr_t)/sizeof(uint16_t); 281 second_index += pointed_to_index*sizeof(uintptr_t)/sizeof(uint16_t);
281 array->As<uint16_t*>()[second_index] = expected; 282 array->As<uint16_t*>()[second_index] = expected;
282 VerifyRead(descriptor, internal_field, array, v8::Integer::New(expected)); 283 VerifyRead(descriptor, internal_field, array, v8::Integer::New(expected));
283 } 284 }
284 285
285 286
286 TEST(HandleDereferenceRead) { 287 TEST(HandleDereferenceRead) {
287 DescriptorTestHelper helper; 288 DescriptorTestHelper helper;
288 v8::HandleScope handle_scope; 289 v8::HandleScope handle_scope;
289 int index = 13; 290 int index = 13;
290 int internal_field = 0; 291 int internal_field = 0;
291 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor = 292 v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
292 OOD::NewInternalFieldDereference(helper.isolate_, internal_field) 293 OOD::NewInternalFieldDereference(helper.isolate_, internal_field)
293 ->NewRawShift(helper.isolate_, index*kPointerSize) 294 ->NewRawShift(helper.isolate_, index*kPointerSize)
294 ->NewHandleDereference(helper.isolate_); 295 ->NewHandleDereference(helper.isolate_);
295 HandleArray* array = *helper.handle_array_; 296 HandleArray* array = *helper.handle_array_;
296 v8::Handle<v8::String> expected = v8_str("whatever"); 297 v8::Handle<v8::String> expected = v8_str("whatever");
297 array->handles_[index] = v8::Persistent<v8::Value>::New(helper.isolate_, 298 array->handles_[index] = v8::Persistent<v8::Value>::New(helper.isolate_,
298 expected); 299 expected);
299 VerifyRead(descriptor, internal_field, array, expected); 300 VerifyRead(descriptor, internal_field, array, expected);
300 } 301 }
301 302
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698