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

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

Issue 1406943006: Pass type argument to Field construction, thus freezing that field, denoting it cannot be changed l… (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: f Created 5 years, 1 month 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
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/parser.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 (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/globals.h" 5 #include "platform/globals.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 // No fields, functions, or super type for the OneFieldClass. 275 // No fields, functions, or super type for the OneFieldClass.
276 EXPECT_EQ(Array::Handle(empty_class.fields()).Length(), 0); 276 EXPECT_EQ(Array::Handle(empty_class.fields()).Length(), 0);
277 EXPECT_EQ(Array::Handle(empty_class.functions()).Length(), 0); 277 EXPECT_EQ(Array::Handle(empty_class.functions()).Length(), 0);
278 EXPECT_EQ(empty_class.super_type(), AbstractType::null()); 278 EXPECT_EQ(empty_class.super_type(), AbstractType::null());
279 ClassFinalizer::FinalizeTypesInClass(one_field_class); 279 ClassFinalizer::FinalizeTypesInClass(one_field_class);
280 280
281 const Array& one_fields = Array::Handle(Array::New(1)); 281 const Array& one_fields = Array::Handle(Array::New(1));
282 const String& field_name = String::Handle(Symbols::New("the_field")); 282 const String& field_name = String::Handle(Symbols::New("the_field"));
283 const Field& field = Field::Handle( 283 const Field& field = Field::Handle(
284 Field::New(field_name, false, false, false, true, one_field_class, 0)); 284 Field::New(field_name, false, false, false, true, one_field_class,
285 Object::dynamic_type(), 0));
285 one_fields.SetAt(0, field); 286 one_fields.SetAt(0, field);
286 one_field_class.SetFields(one_fields); 287 one_field_class.SetFields(one_fields);
287 one_field_class.Finalize(); 288 one_field_class.Finalize();
288 intptr_t header_size = sizeof(RawObject); 289 intptr_t header_size = sizeof(RawObject);
289 EXPECT_EQ(Utils::RoundUp((header_size + (1 * kWordSize)), kObjectAlignment), 290 EXPECT_EQ(Utils::RoundUp((header_size + (1 * kWordSize)), kObjectAlignment),
290 one_field_class.instance_size()); 291 one_field_class.instance_size());
291 EXPECT_EQ(header_size, field.Offset()); 292 EXPECT_EQ(header_size, field.Offset());
292 EXPECT(!one_field_class.is_implemented()); 293 EXPECT(!one_field_class.is_implemented());
293 one_field_class.set_is_implemented(); 294 one_field_class.set_is_implemented();
294 EXPECT(one_field_class.is_implemented()); 295 EXPECT(one_field_class.is_implemented());
(...skipping 2659 matching lines...) Expand 10 before | Expand all | Expand 10 after
2954 const Class& cls = Class::Handle( 2955 const Class& cls = Class::Handle(
2955 CreateDummyClass(class_name, Script::Handle())); 2956 CreateDummyClass(class_name, Script::Handle()));
2956 return cls.raw(); 2957 return cls.raw();
2957 } 2958 }
2958 2959
2959 2960
2960 static RawField* CreateTestField(const char* name) { 2961 static RawField* CreateTestField(const char* name) {
2961 const Class& cls = Class::Handle(CreateTestClass("global:")); 2962 const Class& cls = Class::Handle(CreateTestClass("global:"));
2962 const String& field_name = String::Handle(Symbols::New(name)); 2963 const String& field_name = String::Handle(Symbols::New(name));
2963 const Field& field = 2964 const Field& field =
2964 Field::Handle(Field::New(field_name, true, false, false, true, cls, 0)); 2965 Field::Handle(Field::New(field_name, true, false, false, true, cls,
2966 Object::dynamic_type(), 0));
2965 return field.raw(); 2967 return field.raw();
2966 } 2968 }
2967 2969
2968 2970
2969 TEST_CASE(ClassDictionaryIterator) { 2971 TEST_CASE(ClassDictionaryIterator) {
2970 Class& ae66 = Class::ZoneHandle(CreateTestClass("Ae6/6")); 2972 Class& ae66 = Class::ZoneHandle(CreateTestClass("Ae6/6"));
2971 Class& re44 = Class::ZoneHandle(CreateTestClass("Re4/4")); 2973 Class& re44 = Class::ZoneHandle(CreateTestClass("Re4/4"));
2972 Field& ce68 = Field::ZoneHandle(CreateTestField("Ce6/8")); 2974 Field& ce68 = Field::ZoneHandle(CreateTestField("Ce6/8"));
2973 Field& tee = Field::ZoneHandle(CreateTestField("TEE")); 2975 Field& tee = Field::ZoneHandle(CreateTestField("TEE"));
2974 String& url = String::ZoneHandle(String::New("SBB")); 2976 String& url = String::ZoneHandle(String::New("SBB"));
(...skipping 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after
4785 String& test = String::Handle(); 4787 String& test = String::Handle();
4786 String& result = String::Handle(); 4788 String& result = String::Handle();
4787 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { 4789 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) {
4788 test = String::New(tests[i].in); 4790 test = String::New(tests[i].in);
4789 result = String::IdentifierPrettyName(test); 4791 result = String::IdentifierPrettyName(test);
4790 EXPECT_STREQ(tests[i].out, result.ToCString()); 4792 EXPECT_STREQ(tests[i].out, result.ToCString());
4791 } 4793 }
4792 } 4794 }
4793 4795
4794 } // namespace dart 4796 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698