| 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
| 7 #include "platform/json.h" | 7 #include "platform/json.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 3024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3035 EXPECT(Dart_IsError(result)); | 3035 EXPECT(Dart_IsError(result)); |
| 3036 Dart_Handle expected_error = Dart_Error( | 3036 Dart_Handle expected_error = Dart_Error( |
| 3037 "'dart:test-lib': Error: line 1 pos 38: " | 3037 "'dart:test-lib': Error: line 1 pos 38: " |
| 3038 "class 'NativeFields' is trying to extend a native fields class, " | 3038 "class 'NativeFields' is trying to extend a native fields class, " |
| 3039 "but library '%s' has no native resolvers", | 3039 "but library '%s' has no native resolvers", |
| 3040 TestCase::url()); | 3040 TestCase::url()); |
| 3041 EXPECT_SUBSTRING(Dart_GetError(expected_error), Dart_GetError(result)); | 3041 EXPECT_SUBSTRING(Dart_GetError(expected_error), Dart_GetError(result)); |
| 3042 } | 3042 } |
| 3043 | 3043 |
| 3044 | 3044 |
| 3045 TEST_CASE(InjectNativeFieldsSuperClass) { |
| 3046 const char* kScriptChars = |
| 3047 "#import('dart:nativewrappers');" |
| 3048 "class NativeFieldsSuper extends NativeFieldWrapperClass1 {\n" |
| 3049 " NativeFieldsSuper() : fld1 = 42 {}\n" |
| 3050 " int fld1;\n" |
| 3051 "}\n" |
| 3052 "class NativeFields extends NativeFieldsSuper {\n" |
| 3053 " fld() => fld1;\n" |
| 3054 "}\n" |
| 3055 "int testMain() {\n" |
| 3056 " NativeFields obj = new NativeFields();\n" |
| 3057 " return obj.fld();\n" |
| 3058 "}\n"; |
| 3059 Dart_Handle result; |
| 3060 // Load up a test script in the test library. |
| 3061 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, native_field_lookup); |
| 3062 |
| 3063 // Invoke a function which returns an object of type NativeFields. |
| 3064 result = Dart_Invoke(lib, Dart_NewString("testMain"), 0, NULL); |
| 3065 |
| 3066 EXPECT_VALID(result); |
| 3067 EXPECT(Dart_IsInteger(result)); |
| 3068 int64_t value = 0; |
| 3069 result = Dart_IntegerToInt64(result, &value); |
| 3070 EXPECT_VALID(result); |
| 3071 EXPECT_EQ(42, value); |
| 3072 } |
| 3073 |
| 3074 |
| 3045 static void TestNativeFields(Dart_Handle retobj) { | 3075 static void TestNativeFields(Dart_Handle retobj) { |
| 3046 // Access and set various instance fields of the object. | 3076 // Access and set various instance fields of the object. |
| 3047 Dart_Handle result = Dart_GetField(retobj, Dart_NewString("fld3")); | 3077 Dart_Handle result = Dart_GetField(retobj, Dart_NewString("fld3")); |
| 3048 EXPECT(Dart_IsError(result)); | 3078 EXPECT(Dart_IsError(result)); |
| 3049 result = Dart_GetField(retobj, Dart_NewString("fld0")); | 3079 result = Dart_GetField(retobj, Dart_NewString("fld0")); |
| 3050 EXPECT_VALID(result); | 3080 EXPECT_VALID(result); |
| 3051 EXPECT(Dart_IsNull(result)); | 3081 EXPECT(Dart_IsNull(result)); |
| 3052 result = Dart_GetField(retobj, Dart_NewString("fld1")); | 3082 result = Dart_GetField(retobj, Dart_NewString("fld1")); |
| 3053 EXPECT_VALID(result); | 3083 EXPECT_VALID(result); |
| 3054 int64_t value = 0; | 3084 int64_t value = 0; |
| (...skipping 4058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7113 EXPECT(o2 == reinterpret_cast<void*>(&p2)); | 7143 EXPECT(o2 == reinterpret_cast<void*>(&p2)); |
| 7114 } | 7144 } |
| 7115 Dart_ExitScope(); | 7145 Dart_ExitScope(); |
| 7116 isolate->heap()->CollectGarbage(Heap::kOld); | 7146 isolate->heap()->CollectGarbage(Heap::kOld); |
| 7117 EXPECT_EQ(0, isolate->heap()->PeerCount()); | 7147 EXPECT_EQ(0, isolate->heap()->PeerCount()); |
| 7118 } | 7148 } |
| 7119 | 7149 |
| 7120 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 7150 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 7121 | 7151 |
| 7122 } // namespace dart | 7152 } // namespace dart |
| OLD | NEW |