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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 TEST(APITestBasicMutation) { | 318 TEST(APITestBasicMutation) { |
319 HarmonyIsolate isolate; | 319 HarmonyIsolate isolate; |
320 HandleScope scope; | 320 HandleScope scope; |
321 LocalContext context; | 321 LocalContext context; |
322 Handle<Object> obj = Handle<Object>::Cast(CompileRun( | 322 Handle<Object> obj = Handle<Object>::Cast(CompileRun( |
323 "var records = [];" | 323 "var records = [];" |
324 "var obj = {};" | 324 "var obj = {};" |
325 "function observer(r) { [].push.apply(records, r); };" | 325 "function observer(r) { [].push.apply(records, r); };" |
326 "Object.observe(obj, observer);" | 326 "Object.observe(obj, observer);" |
327 "obj")); | 327 "obj")); |
328 obj->Set(String::New("foo"), Number::New(1)); | 328 obj->Set(String::New("foo"), Number::New(7)); |
329 obj->Set(1, Number::New(2)); | 329 obj->Set(1, Number::New(2)); |
330 // ForceSet should work just as well as Set | 330 // ForceSet should work just as well as Set |
331 obj->ForceSet(String::New("foo"), Number::New(3)); | 331 obj->ForceSet(String::New("foo"), Number::New(3)); |
332 obj->ForceSet(Number::New(1), Number::New(4)); | 332 obj->ForceSet(Number::New(1), Number::New(4)); |
333 // Setting an indexed element via the property setting method | 333 // Setting an indexed element via the property setting method |
334 obj->Set(Number::New(1), Number::New(5)); | 334 obj->Set(Number::New(1), Number::New(5)); |
335 // Setting with a non-String, non-uint32 key | 335 // Setting with a non-String, non-uint32 key |
336 obj->Set(Number::New(1.1), Number::New(6), DontDelete); | 336 obj->Set(Number::New(1.1), Number::New(6), DontDelete); |
337 obj->Delete(String::New("foo")); | 337 obj->Delete(String::New("foo")); |
338 obj->Delete(1); | 338 obj->Delete(1); |
339 obj->ForceDelete(Number::New(1.1)); | 339 obj->ForceDelete(Number::New(1.1)); |
340 | 340 |
341 // Force delivery | 341 // Force delivery |
342 // TODO(adamk): Should the above set methods trigger delivery themselves? | 342 // TODO(adamk): Should the above set methods trigger delivery themselves? |
343 CompileRun("void 0"); | 343 CompileRun("void 0"); |
344 CHECK_EQ(9, CompileRun("records.length")->Int32Value()); | 344 CHECK_EQ(9, CompileRun("records.length")->Int32Value()); |
345 const RecordExpectation expected_records[] = { | 345 const RecordExpectation expected_records[] = { |
346 { obj, "new", "foo", Handle<Value>() }, | 346 { obj, "new", "foo", Handle<Value>() }, |
347 { obj, "new", "1", Handle<Value>() }, | 347 { obj, "new", "1", Handle<Value>() }, |
348 { obj, "updated", "foo", Number::New(1) }, | 348 // Note: use 7 not 1 below, as the latter triggers a nifty VS10 compiler bug |
| 349 // where instead of 1.0, a garbage value would be passed into Number::New. |
| 350 { obj, "updated", "foo", Number::New(7) }, |
349 { obj, "updated", "1", Number::New(2) }, | 351 { obj, "updated", "1", Number::New(2) }, |
350 { obj, "updated", "1", Number::New(4) }, | 352 { obj, "updated", "1", Number::New(4) }, |
351 { obj, "new", "1.1", Handle<Value>() }, | 353 { obj, "new", "1.1", Handle<Value>() }, |
352 { obj, "deleted", "foo", Number::New(3) }, | 354 { obj, "deleted", "foo", Number::New(3) }, |
353 { obj, "deleted", "1", Number::New(5) }, | 355 { obj, "deleted", "1", Number::New(5) }, |
354 { obj, "deleted", "1.1", Number::New(6) } | 356 { obj, "deleted", "1.1", Number::New(6) } |
355 }; | 357 }; |
356 EXPECT_RECORDS(CompileRun("records"), expected_records); | 358 EXPECT_RECORDS(CompileRun("records"), expected_records); |
357 } | 359 } |
358 | 360 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 i::Handle<i::JSWeakMap>::cast( | 427 i::Handle<i::JSWeakMap>::cast( |
426 i::GetProperty(observation_state, "notifierTargetMap")); | 428 i::GetProperty(observation_state, "notifierTargetMap")); |
427 CHECK_EQ(1, NumberOfElements(observerInfoMap)); | 429 CHECK_EQ(1, NumberOfElements(observerInfoMap)); |
428 CHECK_EQ(1, NumberOfElements(objectInfoMap)); | 430 CHECK_EQ(1, NumberOfElements(objectInfoMap)); |
429 CHECK_EQ(1, NumberOfElements(notifierTargetMap)); | 431 CHECK_EQ(1, NumberOfElements(notifierTargetMap)); |
430 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 432 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
431 CHECK_EQ(0, NumberOfElements(observerInfoMap)); | 433 CHECK_EQ(0, NumberOfElements(observerInfoMap)); |
432 CHECK_EQ(0, NumberOfElements(objectInfoMap)); | 434 CHECK_EQ(0, NumberOfElements(objectInfoMap)); |
433 CHECK_EQ(0, NumberOfElements(notifierTargetMap)); | 435 CHECK_EQ(0, NumberOfElements(notifierTargetMap)); |
434 } | 436 } |
OLD | NEW |