| 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 // TODO(zra): Remove when tests are ready to enable. | 5 // TODO(zra): Remove when tests are ready to enable. |
| 6 #include "platform/globals.h" | 6 #include "platform/globals.h" |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 2974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2985 EXPECT(!String::EqualsIgnoringPrivateKey(ext_mangled_name, | 2985 EXPECT(!String::EqualsIgnoringPrivateKey(ext_mangled_name, |
| 2986 ext_bad_bare_name)); | 2986 ext_bad_bare_name)); |
| 2987 } | 2987 } |
| 2988 | 2988 |
| 2989 | 2989 |
| 2990 TEST_CASE(ArrayNew_Overflow_Crash) { | 2990 TEST_CASE(ArrayNew_Overflow_Crash) { |
| 2991 Array::Handle(Array::New(Array::kMaxElements + 1)); | 2991 Array::Handle(Array::New(Array::kMaxElements + 1)); |
| 2992 } | 2992 } |
| 2993 | 2993 |
| 2994 | 2994 |
| 2995 // TODO(zra): Enable test when arm64 is ready. | |
| 2996 #if !defined(TARGET_ARCH_ARM64) | |
| 2997 | |
| 2998 TEST_CASE(StackTraceFormat) { | 2995 TEST_CASE(StackTraceFormat) { |
| 2999 const char* kScriptChars = | 2996 const char* kScriptChars = |
| 3000 "void baz() {\n" | 2997 "void baz() {\n" |
| 3001 " throw 'MyException';\n" | 2998 " throw 'MyException';\n" |
| 3002 "}\n" | 2999 "}\n" |
| 3003 "\n" | 3000 "\n" |
| 3004 "class _OtherClass {\n" | 3001 "class _OtherClass {\n" |
| 3005 " _OtherClass._named() {\n" | 3002 " _OtherClass._named() {\n" |
| 3006 " baz();\n" | 3003 " baz();\n" |
| 3007 " }\n" | 3004 " }\n" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3047 "#2 _bar (dart:test-lib:16:3)\n" | 3044 "#2 _bar (dart:test-lib:16:3)\n" |
| 3048 "#3 MyClass.field (dart:test-lib:25:9)\n" | 3045 "#3 MyClass.field (dart:test-lib:25:9)\n" |
| 3049 "#4 MyClass.foo.fooHelper (dart:test-lib:30:7)\n" | 3046 "#4 MyClass.foo.fooHelper (dart:test-lib:30:7)\n" |
| 3050 "#5 MyClass.foo (dart:test-lib:32:14)\n" | 3047 "#5 MyClass.foo (dart:test-lib:32:14)\n" |
| 3051 "#6 MyClass.MyClass.<anonymous closure> (dart:test-lib:21:15)\n" | 3048 "#6 MyClass.MyClass.<anonymous closure> (dart:test-lib:21:15)\n" |
| 3052 "#7 MyClass.MyClass (dart:test-lib:21:18)\n" | 3049 "#7 MyClass.MyClass (dart:test-lib:21:18)\n" |
| 3053 "#8 main.<anonymous closure> (dart:test-lib:37:14)\n" | 3050 "#8 main.<anonymous closure> (dart:test-lib:37:14)\n" |
| 3054 "#9 main (dart:test-lib:37:24)"); | 3051 "#9 main (dart:test-lib:37:24)"); |
| 3055 } | 3052 } |
| 3056 | 3053 |
| 3057 #endif // !defined(TARGET_ARCH_ARM64) | |
| 3058 | 3054 |
| 3059 TEST_CASE(WeakProperty_PreserveCrossGen) { | 3055 TEST_CASE(WeakProperty_PreserveCrossGen) { |
| 3060 Isolate* isolate = Isolate::Current(); | 3056 Isolate* isolate = Isolate::Current(); |
| 3061 WeakProperty& weak = WeakProperty::Handle(); | 3057 WeakProperty& weak = WeakProperty::Handle(); |
| 3062 { | 3058 { |
| 3063 // Weak property and value in new. Key in old. | 3059 // Weak property and value in new. Key in old. |
| 3064 HANDLESCOPE(isolate); | 3060 HANDLESCOPE(isolate); |
| 3065 String& key = String::Handle(); | 3061 String& key = String::Handle(); |
| 3066 key ^= OneByteString::New("key", Heap::kOld); | 3062 key ^= OneByteString::New("key", Heap::kOld); |
| 3067 String& value = String::Handle(); | 3063 String& value = String::Handle(); |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3456 EXPECT_NE(reference.raw(), other_reference.raw()); | 3452 EXPECT_NE(reference.raw(), other_reference.raw()); |
| 3457 other_reference.set_referent(library); | 3453 other_reference.set_referent(library); |
| 3458 EXPECT_NE(reference.raw(), other_reference.raw()); | 3454 EXPECT_NE(reference.raw(), other_reference.raw()); |
| 3459 EXPECT_EQ(reference.referent(), other_reference.referent()); | 3455 EXPECT_EQ(reference.referent(), other_reference.referent()); |
| 3460 | 3456 |
| 3461 Object& obj = Object::Handle(reference.raw()); | 3457 Object& obj = Object::Handle(reference.raw()); |
| 3462 EXPECT(obj.IsMirrorReference()); | 3458 EXPECT(obj.IsMirrorReference()); |
| 3463 } | 3459 } |
| 3464 | 3460 |
| 3465 | 3461 |
| 3466 // TODO(zra): Enable test when arm64 is ready. | |
| 3467 #if !defined(TARGET_ARCH_ARM64) | |
| 3468 | |
| 3469 static RawFunction* GetFunction(const Class& cls, const char* name) { | 3462 static RawFunction* GetFunction(const Class& cls, const char* name) { |
| 3470 const Function& result = Function::Handle(cls.LookupDynamicFunction( | 3463 const Function& result = Function::Handle(cls.LookupDynamicFunction( |
| 3471 String::Handle(String::New(name)))); | 3464 String::Handle(String::New(name)))); |
| 3472 EXPECT(!result.IsNull()); | 3465 EXPECT(!result.IsNull()); |
| 3473 return result.raw(); | 3466 return result.raw(); |
| 3474 } | 3467 } |
| 3475 | 3468 |
| 3476 | 3469 |
| 3477 static RawFunction* GetStaticFunction(const Class& cls, const char* name) { | 3470 static RawFunction* GetStaticFunction(const Class& cls, const char* name) { |
| 3478 const Function& result = Function::Handle(cls.LookupStaticFunction( | 3471 const Function& result = Function::Handle(cls.LookupStaticFunction( |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3598 func_b_from_index ^= class_a.FunctionFromIndex(func_b_index); | 3591 func_b_from_index ^= class_a.FunctionFromIndex(func_b_index); |
| 3599 EXPECT(!func_b_from_index.IsNull()); | 3592 EXPECT(!func_b_from_index.IsNull()); |
| 3600 // Same function. | 3593 // Same function. |
| 3601 EXPECT_EQ(func_b.raw(), func_b_from_index.raw()); | 3594 EXPECT_EQ(func_b.raw(), func_b_from_index.raw()); |
| 3602 // Retrieve implicit closure function. | 3595 // Retrieve implicit closure function. |
| 3603 Function& func_x_from_index = Function::Handle(); | 3596 Function& func_x_from_index = Function::Handle(); |
| 3604 func_x_from_index ^= class_a.ImplicitClosureFunctionFromIndex(func_x_index); | 3597 func_x_from_index ^= class_a.ImplicitClosureFunctionFromIndex(func_x_index); |
| 3605 EXPECT_EQ(func_x.raw(), func_x_from_index.raw()); | 3598 EXPECT_EQ(func_x.raw(), func_x_from_index.raw()); |
| 3606 } | 3599 } |
| 3607 | 3600 |
| 3608 #endif // !defined(TARGET_ARCH_ARM64) | |
| 3609 | |
| 3610 | 3601 |
| 3611 TEST_CASE(FindClosureIndex) { | 3602 TEST_CASE(FindClosureIndex) { |
| 3612 // Allocate the class first. | 3603 // Allocate the class first. |
| 3613 const String& class_name = String::Handle(Symbols::New("MyClass")); | 3604 const String& class_name = String::Handle(Symbols::New("MyClass")); |
| 3614 const Script& script = Script::Handle(); | 3605 const Script& script = Script::Handle(); |
| 3615 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); | 3606 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); |
| 3616 const Array& functions = Array::Handle(Array::New(1)); | 3607 const Array& functions = Array::Handle(Array::New(1)); |
| 3617 | 3608 |
| 3618 Function& parent = Function::Handle(); | 3609 Function& parent = Function::Handle(); |
| 3619 const String& parent_name = String::Handle(Symbols::New("foo_papa")); | 3610 const String& parent_name = String::Handle(Symbols::New("foo_papa")); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3680 EXPECT_EQ(invocation_dispatcher.raw(), | 3671 EXPECT_EQ(invocation_dispatcher.raw(), |
| 3681 invocation_dispatcher_from_index.raw()); | 3672 invocation_dispatcher_from_index.raw()); |
| 3682 // Test function not found case. | 3673 // Test function not found case. |
| 3683 const Function& bad_function = Function::Handle(Function::null()); | 3674 const Function& bad_function = Function::Handle(Function::null()); |
| 3684 intptr_t bad_invocation_dispatcher_index = | 3675 intptr_t bad_invocation_dispatcher_index = |
| 3685 cls.FindInvocationDispatcherFunctionIndex(bad_function); | 3676 cls.FindInvocationDispatcherFunctionIndex(bad_function); |
| 3686 EXPECT_EQ(bad_invocation_dispatcher_index, -1); | 3677 EXPECT_EQ(bad_invocation_dispatcher_index, -1); |
| 3687 } | 3678 } |
| 3688 | 3679 |
| 3689 | 3680 |
| 3690 // TODO(zra): Enable test when arm64 is ready. | |
| 3691 #if !defined(TARGET_ARCH_ARM64) | |
| 3692 | |
| 3693 static void PrintMetadata(const char* name, const Object& data) { | 3681 static void PrintMetadata(const char* name, const Object& data) { |
| 3694 if (data.IsError()) { | 3682 if (data.IsError()) { |
| 3695 OS::Print("Error in metadata evaluation for %s: '%s'\n", | 3683 OS::Print("Error in metadata evaluation for %s: '%s'\n", |
| 3696 name, | 3684 name, |
| 3697 Error::Cast(data).ToErrorCString()); | 3685 Error::Cast(data).ToErrorCString()); |
| 3698 } | 3686 } |
| 3699 EXPECT(data.IsArray()); | 3687 EXPECT(data.IsArray()); |
| 3700 const Array& metadata = Array::Cast(data); | 3688 const Array& metadata = Array::Cast(data); |
| 3701 OS::Print("Metadata for %s has %" Pd " values:\n", name, metadata.Length()); | 3689 OS::Print("Metadata for %s has %" Pd " values:\n", name, metadata.Length()); |
| 3702 Object& elem = Object::Handle(); | 3690 Object& elem = Object::Handle(); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3850 EXPECT_EQ(a_test1.SourceFingerprint(), b_test1.SourceFingerprint()); | 3838 EXPECT_EQ(a_test1.SourceFingerprint(), b_test1.SourceFingerprint()); |
| 3851 EXPECT_NE(a_test1.SourceFingerprint(), a_test2.SourceFingerprint()); | 3839 EXPECT_NE(a_test1.SourceFingerprint(), a_test2.SourceFingerprint()); |
| 3852 EXPECT_NE(a_test2.SourceFingerprint(), a_test3.SourceFingerprint()); | 3840 EXPECT_NE(a_test2.SourceFingerprint(), a_test3.SourceFingerprint()); |
| 3853 EXPECT_NE(a_test3.SourceFingerprint(), a_test4.SourceFingerprint()); | 3841 EXPECT_NE(a_test3.SourceFingerprint(), a_test4.SourceFingerprint()); |
| 3854 EXPECT_NE(a_test4.SourceFingerprint(), a_test5.SourceFingerprint()); | 3842 EXPECT_NE(a_test4.SourceFingerprint(), a_test5.SourceFingerprint()); |
| 3855 EXPECT_EQ(a_test5.SourceFingerprint(), b_test5.SourceFingerprint()); | 3843 EXPECT_EQ(a_test5.SourceFingerprint(), b_test5.SourceFingerprint()); |
| 3856 EXPECT_NE(a_test6.SourceFingerprint(), b_test6.SourceFingerprint()); | 3844 EXPECT_NE(a_test6.SourceFingerprint(), b_test6.SourceFingerprint()); |
| 3857 } | 3845 } |
| 3858 | 3846 |
| 3859 | 3847 |
| 3848 // TODO(zra): Enable test when arm64 is ready. |
| 3849 #if !defined(TARGET_ARCH_ARM64) |
| 3850 |
| 3860 TEST_CASE(FunctionWithBreakpointNotInlined) { | 3851 TEST_CASE(FunctionWithBreakpointNotInlined) { |
| 3861 const char* kScriptChars = | 3852 const char* kScriptChars = |
| 3862 "class A {\n" | 3853 "class A {\n" |
| 3863 " a() {\n" | 3854 " a() {\n" |
| 3864 " }\n" | 3855 " }\n" |
| 3865 " b() {\n" | 3856 " b() {\n" |
| 3866 " a();\n" // This is line 5. | 3857 " a();\n" // This is line 5. |
| 3867 " }\n" | 3858 " }\n" |
| 3868 "}\n" | 3859 "}\n" |
| 3869 "test() {\n" | 3860 "test() {\n" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3922 cls = Object::dynamic_class(); | 3913 cls = Object::dynamic_class(); |
| 3923 array = cls.fields(); | 3914 array = cls.fields(); |
| 3924 EXPECT(!array.IsNull()); | 3915 EXPECT(!array.IsNull()); |
| 3925 EXPECT(array.IsArray()); | 3916 EXPECT(array.IsArray()); |
| 3926 array = cls.functions(); | 3917 array = cls.functions(); |
| 3927 EXPECT(!array.IsNull()); | 3918 EXPECT(!array.IsNull()); |
| 3928 EXPECT(array.IsArray()); | 3919 EXPECT(array.IsArray()); |
| 3929 } | 3920 } |
| 3930 | 3921 |
| 3931 | 3922 |
| 3932 // TODO(zra): Enable test when arm64 is ready. | |
| 3933 #if !defined(TARGET_ARCH_ARM64) | |
| 3934 | |
| 3935 TEST_CASE(ToUserCString) { | 3923 TEST_CASE(ToUserCString) { |
| 3936 const char* kScriptChars = | 3924 const char* kScriptChars = |
| 3937 "var simple = 'simple';\n" | 3925 "var simple = 'simple';\n" |
| 3938 "var escapes = 'stuff\\n\\r\\f\\b\\t\\v\\'\"\\$stuff';\n" | 3926 "var escapes = 'stuff\\n\\r\\f\\b\\t\\v\\'\"\\$stuff';\n" |
| 3939 "var uescapes = 'stuff\\u0001\\u0002stuff';\n" | 3927 "var uescapes = 'stuff\\u0001\\u0002stuff';\n" |
| 3940 "var toolong = " | 3928 "var toolong = " |
| 3941 "'01234567890123456789012345678901234567890123456789howdy';\n" | 3929 "'01234567890123456789012345678901234567890123456789howdy';\n" |
| 3942 "var toolong2 = " | 3930 "var toolong2 = " |
| 3943 "'0123456789012345678901234567890123\\t567890123456789howdy';\n" | 3931 "'0123456789012345678901234567890123\\t567890123456789howdy';\n" |
| 3944 "var toolong3 = " | 3932 "var toolong3 = " |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4020 }; | 4008 }; |
| 4021 | 4009 |
| 4022 | 4010 |
| 4023 TEST_CASE(PrintJSON) { | 4011 TEST_CASE(PrintJSON) { |
| 4024 Heap* heap = Isolate::Current()->heap(); | 4012 Heap* heap = Isolate::Current()->heap(); |
| 4025 heap->CollectAllGarbage(); | 4013 heap->CollectAllGarbage(); |
| 4026 JSONTypeVerifier verifier; | 4014 JSONTypeVerifier verifier; |
| 4027 heap->IterateObjects(&verifier); | 4015 heap->IterateObjects(&verifier); |
| 4028 } | 4016 } |
| 4029 | 4017 |
| 4030 #endif // !defined(TARGET_ARCH_ARM64) | |
| 4031 | |
| 4032 } // namespace dart | 4018 } // namespace dart |
| OLD | NEW |