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 3262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3273 EXPECT(Dart_IsError(result)); | 3273 EXPECT(Dart_IsError(result)); |
3274 result = Dart_SetNativeInstanceField(retobj, kNativeFld4, 40); | 3274 result = Dart_SetNativeInstanceField(retobj, kNativeFld4, 40); |
3275 EXPECT(Dart_IsError(result)); | 3275 EXPECT(Dart_IsError(result)); |
3276 result = Dart_SetNativeInstanceField(retobj, kNativeFld3, 40); | 3276 result = Dart_SetNativeInstanceField(retobj, kNativeFld3, 40); |
3277 EXPECT(Dart_IsError(result)); | 3277 EXPECT(Dart_IsError(result)); |
3278 result = Dart_SetNativeInstanceField(retobj, kNativeFld0, 400); | 3278 result = Dart_SetNativeInstanceField(retobj, kNativeFld0, 400); |
3279 EXPECT(Dart_IsError(result)); | 3279 EXPECT(Dart_IsError(result)); |
3280 } | 3280 } |
3281 | 3281 |
3282 | 3282 |
| 3283 TEST_CASE(NegativeNativeFieldInIsolateMessage) { |
| 3284 const char* kScriptChars = |
| 3285 "import 'dart:isolate';\n" |
| 3286 "import 'dart:nativewrappers';\n" |
| 3287 "echo() {\n" |
| 3288 " port.receive((msg, reply) {\n" |
| 3289 " reply.send('echoing ${msg(1)}}');\n" |
| 3290 " });\n" |
| 3291 "}\n" |
| 3292 "class Test extends NativeFieldWrapperClass2 {\n" |
| 3293 " Test(this.i, this.j);\n" |
| 3294 " int i, j;\n" |
| 3295 "}\n" |
| 3296 "main() {\n" |
| 3297 " var snd = spawnFunction(echo);\n" |
| 3298 " var obj = new Test(1,2);\n" |
| 3299 " snd.send(obj, port.toSendPort());\n" |
| 3300 " port.receive((msg, reply) {\n" |
| 3301 " print('from worker ${msg}');\n" |
| 3302 " });\n" |
| 3303 "}\n"; |
| 3304 |
| 3305 DARTSCOPE_NOCHECKS(Isolate::Current()); |
| 3306 |
| 3307 // Create a test library and Load up a test script in it. |
| 3308 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 3309 |
| 3310 // Invoke 'main' which should spawn an isolate and try to send an |
| 3311 // object with native fields over to the spawned isolate. This |
| 3312 // should result in an unhandled exception which is checked. |
| 3313 Dart_Handle retobj = Dart_Invoke(lib, NewString("main"), 0, NULL); |
| 3314 EXPECT(Dart_IsError(retobj)); |
| 3315 } |
| 3316 |
| 3317 |
3283 TEST_CASE(GetStaticField_RunsInitializer) { | 3318 TEST_CASE(GetStaticField_RunsInitializer) { |
3284 const char* kScriptChars = | 3319 const char* kScriptChars = |
3285 "class TestClass {\n" | 3320 "class TestClass {\n" |
3286 " static const int fld1 = 7;\n" | 3321 " static const int fld1 = 7;\n" |
3287 " static int fld2 = 11;\n" | 3322 " static int fld2 = 11;\n" |
3288 " static void testMain() {\n" | 3323 " static void testMain() {\n" |
3289 " }\n" | 3324 " }\n" |
3290 "}\n"; | 3325 "}\n"; |
3291 Dart_Handle result; | 3326 Dart_Handle result; |
3292 // Create a test library and Load up a test script in it. | 3327 // Create a test library and Load up a test script in it. |
(...skipping 3865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7158 EXPECT(o2 == reinterpret_cast<void*>(&p2)); | 7193 EXPECT(o2 == reinterpret_cast<void*>(&p2)); |
7159 } | 7194 } |
7160 Dart_ExitScope(); | 7195 Dart_ExitScope(); |
7161 isolate->heap()->CollectGarbage(Heap::kOld); | 7196 isolate->heap()->CollectGarbage(Heap::kOld); |
7162 EXPECT_EQ(0, isolate->heap()->PeerCount()); | 7197 EXPECT_EQ(0, isolate->heap()->PeerCount()); |
7163 } | 7198 } |
7164 | 7199 |
7165 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 7200 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
7166 | 7201 |
7167 } // namespace dart | 7202 } // namespace dart |
OLD | NEW |