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

Side by Side Diff: runtime/vm/object_test.cc

Issue 10521004: Eliminate RawObject::class_ field entirely. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/assembler.h" 6 #include "vm/assembler.h"
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
(...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 } 1779 }
1780 EXPECT_EQ(10, array.Length()); 1780 EXPECT_EQ(10, array.Length());
1781 for (intptr_t i = 0; i < 10; i++) { 1781 for (intptr_t i = 0; i < 10; i++) {
1782 expected_value = Smi::New(i * 10); 1782 expected_value = Smi::New(i * 10);
1783 value ^= array.At(i); 1783 value ^= array.At(i);
1784 EXPECT(value.Equals(expected_value)); 1784 EXPECT(value.Equals(expected_value));
1785 } 1785 }
1786 1786
1787 // Test the MakeArray functionality to make sure the resulting array 1787 // Test the MakeArray functionality to make sure the resulting array
1788 // object is properly setup. 1788 // object is properly setup.
1789 // 1. Should produce an array of length 2 and a remainder array of length 0. 1789 // 1. Should produce an array of length 2 and a remainder array of length 1.
1790 Array& new_array = Array::Handle(); 1790 Array& new_array = Array::Handle();
1791 Object& obj = Object::Handle(); 1791 Object& obj = Object::Handle();
1792 uword addr = 0; 1792 uword addr = 0;
1793 intptr_t used_size = 0; 1793 intptr_t used_size = 0;
1794 1794
1795 array = GrowableObjectArray::New(kArrayLen); 1795 array = GrowableObjectArray::New(kArrayLen + 1);
1796 EXPECT_EQ(kArrayLen, array.Capacity()); 1796 EXPECT_EQ(kArrayLen + 1, array.Capacity());
1797 EXPECT_EQ(0, array.Length()); 1797 EXPECT_EQ(0, array.Length());
1798 for (intptr_t i = 0; i < 2; i++) { 1798 for (intptr_t i = 0; i < 2; i++) {
1799 value = Smi::New(i); 1799 value = Smi::New(i);
1800 array.Add(value); 1800 array.Add(value);
1801 } 1801 }
1802 used_size = Array::InstanceSize(array.Length()); 1802 used_size = Array::InstanceSize(array.Length());
1803 new_array = Array::MakeArray(array); 1803 new_array = Array::MakeArray(array);
1804 addr = RawObject::ToAddr(new_array.raw()); 1804 addr = RawObject::ToAddr(new_array.raw());
1805 obj = RawObject::FromAddr(addr); 1805 obj = RawObject::FromAddr(addr);
1806 EXPECT(obj.IsArray()); 1806 EXPECT(obj.IsArray());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 new_array = Array::MakeArray(array); 1843 new_array = Array::MakeArray(array);
1844 addr = RawObject::ToAddr(new_array.raw()); 1844 addr = RawObject::ToAddr(new_array.raw());
1845 obj = RawObject::FromAddr(addr); 1845 obj = RawObject::FromAddr(addr);
1846 EXPECT(obj.IsArray()); 1846 EXPECT(obj.IsArray());
1847 new_array ^= obj.raw(); 1847 new_array ^= obj.raw();
1848 EXPECT_EQ(1, new_array.Length()); 1848 EXPECT_EQ(1, new_array.Length());
1849 addr += used_size; 1849 addr += used_size;
1850 obj = RawObject::FromAddr(addr); 1850 obj = RawObject::FromAddr(addr);
1851 EXPECT(obj.IsArray()); 1851 EXPECT(obj.IsArray());
1852 new_array ^= obj.raw(); 1852 new_array ^= obj.raw();
1853 EXPECT_EQ(2, new_array.Length()); 1853 EXPECT_EQ(4, new_array.Length());
1854 } 1854 }
1855 1855
1856 1856
1857 TEST_CASE(InternalByteArray) { 1857 TEST_CASE(InternalByteArray) {
1858 uint8_t data[] = { 253, 254, 255, 0, 1, 2, 3, 4 }; 1858 uint8_t data[] = { 253, 254, 255, 0, 1, 2, 3, 4 };
1859 intptr_t data_length = ARRAY_SIZE(data); 1859 intptr_t data_length = ARRAY_SIZE(data);
1860 1860
1861 const Int8Array& int8_array = 1861 const Int8Array& int8_array =
1862 Int8Array::Handle(Int8Array::New(reinterpret_cast<int8_t*>(data), 1862 Int8Array::Handle(Int8Array::New(reinterpret_cast<int8_t*>(data),
1863 data_length)); 1863 data_length));
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
2656 cache.GetCheck(0, &test_class, &test_targ_0, &test_targ_1, &test_result); 2656 cache.GetCheck(0, &test_class, &test_targ_0, &test_targ_1, &test_result);
2657 EXPECT_EQ(empty_class.raw(), test_class.raw()); 2657 EXPECT_EQ(empty_class.raw(), test_class.raw());
2658 EXPECT_EQ(targ_0.raw(), test_targ_0.raw()); 2658 EXPECT_EQ(targ_0.raw(), test_targ_0.raw());
2659 EXPECT_EQ(targ_1.raw(), test_targ_1.raw()); 2659 EXPECT_EQ(targ_1.raw(), test_targ_1.raw());
2660 EXPECT_EQ(Bool::True(), test_result.raw()); 2660 EXPECT_EQ(Bool::True(), test_result.raw());
2661 } 2661 }
2662 2662
2663 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 2663 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
2664 2664
2665 } // namespace dart 2665 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698