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

Side by Side Diff: test/cctest/test-heap.cc

Issue 7187007: Merge arguments branch to bleeding edge (second try). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Undelete external-array test. Created 9 years, 6 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 | « test/cctest/test-api.cc ('k') | test/mjsunit/arguments.js » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 2
3 #include <stdlib.h> 3 #include <stdlib.h>
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "execution.h" 7 #include "execution.h"
8 #include "factory.h" 8 #include "factory.h"
9 #include "macro-assembler.h" 9 #include "macro-assembler.h"
10 #include "global-handles.h" 10 #include "global-handles.h"
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 Handle<JSArray> array = Handle<JSArray>::cast(object); 668 Handle<JSArray> array = Handle<JSArray>::cast(object);
669 // We just initialized the VM, no heap allocation failure yet. 669 // We just initialized the VM, no heap allocation failure yet.
670 Object* ok = array->Initialize(0)->ToObjectChecked(); 670 Object* ok = array->Initialize(0)->ToObjectChecked();
671 671
672 // Set array length to 0. 672 // Set array length to 0.
673 ok = array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked(); 673 ok = array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked();
674 CHECK_EQ(Smi::FromInt(0), array->length()); 674 CHECK_EQ(Smi::FromInt(0), array->length());
675 CHECK(array->HasFastElements()); // Must be in fast mode. 675 CHECK(array->HasFastElements()); // Must be in fast mode.
676 676
677 // array[length] = name. 677 // array[length] = name.
678 ok = array->SetElement(0, *name, kNonStrictMode)->ToObjectChecked(); 678 ok = array->SetElement(0, *name, kNonStrictMode, true)->ToObjectChecked();
679 CHECK_EQ(Smi::FromInt(1), array->length()); 679 CHECK_EQ(Smi::FromInt(1), array->length());
680 CHECK_EQ(array->GetElement(0), *name); 680 CHECK_EQ(array->GetElement(0), *name);
681 681
682 // Set array length with larger than smi value. 682 // Set array length with larger than smi value.
683 Handle<Object> length = 683 Handle<Object> length =
684 FACTORY->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1); 684 FACTORY->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1);
685 ok = array->SetElementsLength(*length)->ToObjectChecked(); 685 ok = array->SetElementsLength(*length)->ToObjectChecked();
686 686
687 uint32_t int_length = 0; 687 uint32_t int_length = 0;
688 CHECK(length->ToArrayIndex(&int_length)); 688 CHECK(length->ToArrayIndex(&int_length));
689 CHECK_EQ(*length, array->length()); 689 CHECK_EQ(*length, array->length());
690 CHECK(array->HasDictionaryElements()); // Must be in slow mode. 690 CHECK(array->HasDictionaryElements()); // Must be in slow mode.
691 691
692 // array[length] = name. 692 // array[length] = name.
693 ok = array->SetElement(int_length, *name, kNonStrictMode)->ToObjectChecked(); 693 ok = array->SetElement(
694 int_length, *name, kNonStrictMode, true)->ToObjectChecked();
694 uint32_t new_int_length = 0; 695 uint32_t new_int_length = 0;
695 CHECK(array->length()->ToArrayIndex(&new_int_length)); 696 CHECK(array->length()->ToArrayIndex(&new_int_length));
696 CHECK_EQ(static_cast<double>(int_length), new_int_length - 1); 697 CHECK_EQ(static_cast<double>(int_length), new_int_length - 1);
697 CHECK_EQ(array->GetElement(int_length), *name); 698 CHECK_EQ(array->GetElement(int_length), *name);
698 CHECK_EQ(array->GetElement(0), *name); 699 CHECK_EQ(array->GetElement(0), *name);
699 } 700 }
700 701
701 702
702 TEST(JSObjectCopy) { 703 TEST(JSObjectCopy) {
703 InitializeVM(); 704 InitializeVM();
704 705
705 v8::HandleScope sc; 706 v8::HandleScope sc;
706 String* object_symbol = String::cast(HEAP->Object_symbol()); 707 String* object_symbol = String::cast(HEAP->Object_symbol());
707 Object* raw_object = Isolate::Current()->context()->global()-> 708 Object* raw_object = Isolate::Current()->context()->global()->
708 GetProperty(object_symbol)->ToObjectChecked(); 709 GetProperty(object_symbol)->ToObjectChecked();
709 JSFunction* object_function = JSFunction::cast(raw_object); 710 JSFunction* object_function = JSFunction::cast(raw_object);
710 Handle<JSFunction> constructor(object_function); 711 Handle<JSFunction> constructor(object_function);
711 Handle<JSObject> obj = FACTORY->NewJSObject(constructor); 712 Handle<JSObject> obj = FACTORY->NewJSObject(constructor);
712 Handle<String> first = FACTORY->LookupAsciiSymbol("first"); 713 Handle<String> first = FACTORY->LookupAsciiSymbol("first");
713 Handle<String> second = FACTORY->LookupAsciiSymbol("second"); 714 Handle<String> second = FACTORY->LookupAsciiSymbol("second");
714 715
715 obj->SetProperty( 716 obj->SetProperty(
716 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); 717 *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
717 obj->SetProperty( 718 obj->SetProperty(
718 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); 719 *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
719 720
720 Object* ok = obj->SetElement(0, *first, kNonStrictMode)->ToObjectChecked(); 721 Object* ok =
722 obj->SetElement(0, *first, kNonStrictMode, true)->ToObjectChecked();
721 723
722 ok = obj->SetElement(1, *second, kNonStrictMode)->ToObjectChecked(); 724 ok = obj->SetElement(1, *second, kNonStrictMode, true)->ToObjectChecked();
723 725
724 // Make the clone. 726 // Make the clone.
725 Handle<JSObject> clone = Copy(obj); 727 Handle<JSObject> clone = Copy(obj);
726 CHECK(!clone.is_identical_to(obj)); 728 CHECK(!clone.is_identical_to(obj));
727 729
728 CHECK_EQ(obj->GetElement(0), clone->GetElement(0)); 730 CHECK_EQ(obj->GetElement(0), clone->GetElement(0));
729 CHECK_EQ(obj->GetElement(1), clone->GetElement(1)); 731 CHECK_EQ(obj->GetElement(1), clone->GetElement(1));
730 732
731 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*first)); 733 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*first));
732 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second)); 734 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second));
733 735
734 // Flip the values. 736 // Flip the values.
735 clone->SetProperty( 737 clone->SetProperty(
736 *first, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); 738 *first, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked();
737 clone->SetProperty( 739 clone->SetProperty(
738 *second, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); 740 *second, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
739 741
740 ok = clone->SetElement(0, *second, kNonStrictMode)->ToObjectChecked(); 742 ok = clone->SetElement(0, *second, kNonStrictMode, true)->ToObjectChecked();
741 ok = clone->SetElement(1, *first, kNonStrictMode)->ToObjectChecked(); 743 ok = clone->SetElement(1, *first, kNonStrictMode, true)->ToObjectChecked();
742 744
743 CHECK_EQ(obj->GetElement(1), clone->GetElement(0)); 745 CHECK_EQ(obj->GetElement(1), clone->GetElement(0));
744 CHECK_EQ(obj->GetElement(0), clone->GetElement(1)); 746 CHECK_EQ(obj->GetElement(0), clone->GetElement(1));
745 747
746 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first)); 748 CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*first));
747 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second)); 749 CHECK_EQ(obj->GetProperty(*first), clone->GetProperty(*second));
748 } 750 }
749 751
750 752
751 TEST(StringAllocation) { 753 TEST(StringAllocation) {
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 CHECK(helper.b_found()); 1320 CHECK(helper.b_found());
1319 } 1321 }
1320 // ...but is now unreachable. 1322 // ...but is now unreachable.
1321 { 1323 {
1322 HeapIteratorTestHelper helper(a_saved, *b); 1324 HeapIteratorTestHelper helper(a_saved, *b);
1323 helper.IterateHeap(HeapIterator::kFilterUnreachable); 1325 helper.IterateHeap(HeapIterator::kFilterUnreachable);
1324 CHECK(!helper.a_found()); 1326 CHECK(!helper.a_found());
1325 CHECK(helper.b_found()); 1327 CHECK(helper.b_found());
1326 } 1328 }
1327 } 1329 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/mjsunit/arguments.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698