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 2645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2683 EXPECT(!str3.IsOneByteString()); | 2679 EXPECT(!str3.IsOneByteString()); |
2684 str3 = String::New("Steep and Deep!"); | 2680 str3 = String::New("Steep and Deep!"); |
2685 EXPECT(str3.IsString()); | 2681 EXPECT(str3.IsString()); |
2686 EXPECT(str3.IsOneByteString()); | 2682 EXPECT(str3.IsOneByteString()); |
2687 str3 = OneByteString::null(); | 2683 str3 = OneByteString::null(); |
2688 EXPECT(str3.IsString()); | 2684 EXPECT(str3.IsString()); |
2689 EXPECT(!str3.IsOneByteString()); | 2685 EXPECT(!str3.IsOneByteString()); |
2690 } | 2686 } |
2691 | 2687 |
2692 | 2688 |
| 2689 #if !defined(TARGET_ARCH_DBC) |
| 2690 static RawLibrary* CreateDummyLibrary(const String& library_name) { |
| 2691 return Library::New(library_name); |
| 2692 } |
| 2693 |
| 2694 |
2693 static RawFunction* CreateFunction(const char* name) { | 2695 static RawFunction* CreateFunction(const char* name) { |
2694 Thread* thread = Thread::Current(); | 2696 Thread* thread = Thread::Current(); |
2695 const String& class_name = String::Handle(Symbols::New(thread, "ownerClass")); | 2697 const String& class_name = String::Handle(Symbols::New(thread, "ownerClass")); |
2696 const String& lib_name = String::Handle(Symbols::New(thread, "ownerLibrary")); | 2698 const String& lib_name = String::Handle(Symbols::New(thread, "ownerLibrary")); |
2697 const Script& script = Script::Handle(); | 2699 const Script& script = Script::Handle(); |
2698 const Class& owner_class = | 2700 const Class& owner_class = |
2699 Class::Handle(CreateDummyClass(class_name, script)); | 2701 Class::Handle(CreateDummyClass(class_name, script)); |
2700 const Library& owner_library = | 2702 const Library& owner_library = |
2701 Library::Handle(CreateDummyLibrary(lib_name)); | 2703 Library::Handle(CreateDummyLibrary(lib_name)); |
2702 owner_class.set_library(owner_library); | 2704 owner_class.set_library(owner_library); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2959 EXPECT_EQ(true, iter.MoveNext()); | 2961 EXPECT_EQ(true, iter.MoveNext()); |
2960 EXPECT_EQ(150, iter.TokenPos().value()); | 2962 EXPECT_EQ(150, iter.TokenPos().value()); |
2961 | 2963 |
2962 EXPECT_EQ(3, iter.TryIndex()); | 2964 EXPECT_EQ(3, iter.TryIndex()); |
2963 EXPECT_EQ(static_cast<uword>(800), iter.PcOffset()); | 2965 EXPECT_EQ(static_cast<uword>(800), iter.PcOffset()); |
2964 EXPECT_EQ(150, iter.TokenPos().value()); | 2966 EXPECT_EQ(150, iter.TokenPos().value()); |
2965 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind()); | 2967 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind()); |
2966 | 2968 |
2967 EXPECT_EQ(false, iter.MoveNext()); | 2969 EXPECT_EQ(false, iter.MoveNext()); |
2968 } | 2970 } |
| 2971 #endif // !defined(TARGET_ARCH_DBC) |
2969 | 2972 |
2970 | 2973 |
2971 static RawClass* CreateTestClass(const char* name) { | 2974 static RawClass* CreateTestClass(const char* name) { |
2972 const String& class_name = String::Handle(Symbols::New(Thread::Current(), | 2975 const String& class_name = String::Handle(Symbols::New(Thread::Current(), |
2973 name)); | 2976 name)); |
2974 const Class& cls = Class::Handle( | 2977 const Class& cls = Class::Handle( |
2975 CreateDummyClass(class_name, Script::Handle())); | 2978 CreateDummyClass(class_name, Script::Handle())); |
2976 return cls.raw(); | 2979 return cls.raw(); |
2977 } | 2980 } |
2978 | 2981 |
(...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4723 String& test = String::Handle(); | 4726 String& test = String::Handle(); |
4724 String& result = String::Handle(); | 4727 String& result = String::Handle(); |
4725 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { | 4728 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { |
4726 test = String::New(tests[i].in); | 4729 test = String::New(tests[i].in); |
4727 result = String::ScrubName(test); | 4730 result = String::ScrubName(test); |
4728 EXPECT_STREQ(tests[i].out, result.ToCString()); | 4731 EXPECT_STREQ(tests[i].out, result.ToCString()); |
4729 } | 4732 } |
4730 } | 4733 } |
4731 | 4734 |
4732 } // namespace dart | 4735 } // namespace dart |
OLD | NEW |