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