| OLD | NEW |
| 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" |
| 11 #include "vm/debugger.h" | 11 #include "vm/debugger.h" |
| 12 #include "vm/isolate.h" | 12 #include "vm/isolate.h" |
| 13 #include "vm/object.h" | 13 #include "vm/object.h" |
| 14 #include "vm/object_store.h" | 14 #include "vm/object_store.h" |
| 15 #include "vm/simulator.h" | 15 #include "vm/simulator.h" |
| 16 #include "vm/symbols.h" | 16 #include "vm/symbols.h" |
| 17 #include "vm/unit_test.h" | 17 #include "vm/unit_test.h" |
| 18 #include "vm/code_descriptors.h" | 18 #include "vm/code_descriptors.h" |
| 19 | 19 |
| 20 namespace dart { | 20 namespace dart { |
| 21 | 21 |
| 22 DECLARE_FLAG(bool, write_protect_code); | 22 DECLARE_FLAG(bool, write_protect_code); |
| 23 | 23 |
| 24 static RawLibrary* CreateDummyLibrary(const String& library_name) { | |
| 25 return Library::New(library_name); | |
| 26 } | |
| 27 | |
| 28 | 24 |
| 29 static RawClass* CreateDummyClass(const String& class_name, | 25 static RawClass* CreateDummyClass(const String& class_name, |
| 30 const Script& script) { | 26 const Script& script) { |
| 31 const Class& cls = Class::Handle( | 27 const Class& cls = Class::Handle( |
| 32 Class::New(class_name, script, TokenPosition::kNoSource)); | 28 Class::New(class_name, script, TokenPosition::kNoSource)); |
| 33 cls.set_is_synthesized_class(); // Dummy class for testing. | 29 cls.set_is_synthesized_class(); // Dummy class for testing. |
| 34 return cls.raw(); | 30 return cls.raw(); |
| 35 } | 31 } |
| 36 | 32 |
| 37 | 33 |
| (...skipping 2644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2682 EXPECT(!str3.IsOneByteString()); | 2678 EXPECT(!str3.IsOneByteString()); |
| 2683 str3 = String::New("Steep and Deep!"); | 2679 str3 = String::New("Steep and Deep!"); |
| 2684 EXPECT(str3.IsString()); | 2680 EXPECT(str3.IsString()); |
| 2685 EXPECT(str3.IsOneByteString()); | 2681 EXPECT(str3.IsOneByteString()); |
| 2686 str3 = OneByteString::null(); | 2682 str3 = OneByteString::null(); |
| 2687 EXPECT(str3.IsString()); | 2683 EXPECT(str3.IsString()); |
| 2688 EXPECT(!str3.IsOneByteString()); | 2684 EXPECT(!str3.IsOneByteString()); |
| 2689 } | 2685 } |
| 2690 | 2686 |
| 2691 | 2687 |
| 2688 #if !defined(TARGET_ARCH_DBC) |
| 2689 static RawLibrary* CreateDummyLibrary(const String& library_name) { |
| 2690 return Library::New(library_name); |
| 2691 } |
| 2692 |
| 2693 |
| 2692 static RawFunction* CreateFunction(const char* name) { | 2694 static RawFunction* CreateFunction(const char* name) { |
| 2693 const String& class_name = String::Handle(Symbols::New("ownerClass")); | 2695 const String& class_name = String::Handle(Symbols::New("ownerClass")); |
| 2694 const String& lib_name = String::Handle(Symbols::New("ownerLibrary")); | 2696 const String& lib_name = String::Handle(Symbols::New("ownerLibrary")); |
| 2695 const Script& script = Script::Handle(); | 2697 const Script& script = Script::Handle(); |
| 2696 const Class& owner_class = | 2698 const Class& owner_class = |
| 2697 Class::Handle(CreateDummyClass(class_name, script)); | 2699 Class::Handle(CreateDummyClass(class_name, script)); |
| 2698 const Library& owner_library = | 2700 const Library& owner_library = |
| 2699 Library::Handle(CreateDummyLibrary(lib_name)); | 2701 Library::Handle(CreateDummyLibrary(lib_name)); |
| 2700 owner_class.set_library(owner_library); | 2702 owner_class.set_library(owner_library); |
| 2701 const String& function_name = String::ZoneHandle(Symbols::New(name)); | 2703 const String& function_name = String::ZoneHandle(Symbols::New(name)); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2957 EXPECT_EQ(true, iter.MoveNext()); | 2959 EXPECT_EQ(true, iter.MoveNext()); |
| 2958 EXPECT_EQ(150, iter.TokenPos().value()); | 2960 EXPECT_EQ(150, iter.TokenPos().value()); |
| 2959 | 2961 |
| 2960 EXPECT_EQ(3, iter.TryIndex()); | 2962 EXPECT_EQ(3, iter.TryIndex()); |
| 2961 EXPECT_EQ(static_cast<uword>(800), iter.PcOffset()); | 2963 EXPECT_EQ(static_cast<uword>(800), iter.PcOffset()); |
| 2962 EXPECT_EQ(150, iter.TokenPos().value()); | 2964 EXPECT_EQ(150, iter.TokenPos().value()); |
| 2963 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind()); | 2965 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind()); |
| 2964 | 2966 |
| 2965 EXPECT_EQ(false, iter.MoveNext()); | 2967 EXPECT_EQ(false, iter.MoveNext()); |
| 2966 } | 2968 } |
| 2969 #endif |
| 2967 | 2970 |
| 2968 | 2971 |
| 2969 static RawClass* CreateTestClass(const char* name) { | 2972 static RawClass* CreateTestClass(const char* name) { |
| 2970 const String& class_name = String::Handle(Symbols::New(name)); | 2973 const String& class_name = String::Handle(Symbols::New(name)); |
| 2971 const Class& cls = Class::Handle( | 2974 const Class& cls = Class::Handle( |
| 2972 CreateDummyClass(class_name, Script::Handle())); | 2975 CreateDummyClass(class_name, Script::Handle())); |
| 2973 return cls.raw(); | 2976 return cls.raw(); |
| 2974 } | 2977 } |
| 2975 | 2978 |
| 2976 | 2979 |
| (...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4715 String& test = String::Handle(); | 4718 String& test = String::Handle(); |
| 4716 String& result = String::Handle(); | 4719 String& result = String::Handle(); |
| 4717 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { | 4720 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { |
| 4718 test = String::New(tests[i].in); | 4721 test = String::New(tests[i].in); |
| 4719 result = String::ScrubName(test); | 4722 result = String::ScrubName(test); |
| 4720 EXPECT_STREQ(tests[i].out, result.ToCString()); | 4723 EXPECT_STREQ(tests[i].out, result.ToCString()); |
| 4721 } | 4724 } |
| 4722 } | 4725 } |
| 4723 | 4726 |
| 4724 } // namespace dart | 4727 } // namespace dart |
| OLD | NEW |