| 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/utils.h" | 7 #include "platform/utils.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_api_state.h" | 10 #include "vm/dart_api_state.h" |
| (...skipping 2781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2792 EXPECT_STREQ("Dart_LookupLibrary: library 'noodles.dart' not found.", | 2792 EXPECT_STREQ("Dart_LookupLibrary: library 'noodles.dart' not found.", |
| 2793 Dart_GetError(result)); | 2793 Dart_GetError(result)); |
| 2794 } | 2794 } |
| 2795 | 2795 |
| 2796 | 2796 |
| 2797 TEST_CASE(LibraryUrl) { | 2797 TEST_CASE(LibraryUrl) { |
| 2798 const char* kLibrary1Chars = | 2798 const char* kLibrary1Chars = |
| 2799 "#library('library1_name');"; | 2799 "#library('library1_name');"; |
| 2800 Dart_Handle url = Dart_NewString("library1_url"); | 2800 Dart_Handle url = Dart_NewString("library1_url"); |
| 2801 Dart_Handle source = Dart_NewString(kLibrary1Chars); | 2801 Dart_Handle source = Dart_NewString(kLibrary1Chars); |
| 2802 Dart_Handle import_map = Dart_NewList(0); | 2802 Dart_Handle lib = Dart_LoadLibrary(url, source, Dart_Null()); |
| 2803 Dart_Handle lib = Dart_LoadLibrary(url, source, import_map); | |
| 2804 Dart_Handle error = Dart_Error("incoming error"); | 2803 Dart_Handle error = Dart_Error("incoming error"); |
| 2805 EXPECT_VALID(lib); | 2804 EXPECT_VALID(lib); |
| 2806 | 2805 |
| 2807 Dart_Handle result = Dart_LibraryUrl(Dart_Null()); | 2806 Dart_Handle result = Dart_LibraryUrl(Dart_Null()); |
| 2808 EXPECT(Dart_IsError(result)); | 2807 EXPECT(Dart_IsError(result)); |
| 2809 EXPECT_STREQ("Dart_LibraryUrl expects argument 'library' to be non-null.", | 2808 EXPECT_STREQ("Dart_LibraryUrl expects argument 'library' to be non-null.", |
| 2810 Dart_GetError(result)); | 2809 Dart_GetError(result)); |
| 2811 | 2810 |
| 2812 result = Dart_LibraryUrl(Dart_True()); | 2811 result = Dart_LibraryUrl(Dart_True()); |
| 2813 EXPECT(Dart_IsError(result)); | 2812 EXPECT(Dart_IsError(result)); |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3167 "#library('library1.dart');" | 3166 "#library('library1.dart');" |
| 3168 "#import('library2.dart');" | 3167 "#import('library2.dart');" |
| 3169 "var foo1;"; | 3168 "var foo1;"; |
| 3170 const char* kLibrary2Chars = | 3169 const char* kLibrary2Chars = |
| 3171 "#library('library2.dart');" | 3170 "#library('library2.dart');" |
| 3172 "var foo;"; | 3171 "var foo;"; |
| 3173 Dart_Handle result; | 3172 Dart_Handle result; |
| 3174 // Create a test library and Load up a test script in it. | 3173 // Create a test library and Load up a test script in it. |
| 3175 Dart_Handle url = Dart_NewString(TestCase::url()); | 3174 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 3176 Dart_Handle source = Dart_NewString(kScriptChars); | 3175 Dart_Handle source = Dart_NewString(kScriptChars); |
| 3177 Dart_Handle import_map = Dart_NewList(0); | 3176 result = Dart_LoadScript(url, source, library_handler, Dart_Null()); |
| 3178 result = Dart_LoadScript(url, source, library_handler, import_map); | |
| 3179 | 3177 |
| 3180 url = Dart_NewString("library1.dart"); | 3178 url = Dart_NewString("library1.dart"); |
| 3181 source = Dart_NewString(kLibrary1Chars); | 3179 source = Dart_NewString(kLibrary1Chars); |
| 3182 Dart_LoadLibrary(url, source, import_map); | 3180 Dart_LoadLibrary(url, source, Dart_Null()); |
| 3183 | 3181 |
| 3184 url = Dart_NewString("library2.dart"); | 3182 url = Dart_NewString("library2.dart"); |
| 3185 source = Dart_NewString(kLibrary2Chars); | 3183 source = Dart_NewString(kLibrary2Chars); |
| 3186 Dart_LoadLibrary(url, source, import_map); | 3184 Dart_LoadLibrary(url, source, Dart_Null()); |
| 3187 | 3185 |
| 3188 result = Dart_InvokeStatic(result, | 3186 result = Dart_InvokeStatic(result, |
| 3189 Dart_NewString(""), | 3187 Dart_NewString(""), |
| 3190 Dart_NewString("main"), | 3188 Dart_NewString("main"), |
| 3191 0, | 3189 0, |
| 3192 NULL); | 3190 NULL); |
| 3193 EXPECT(Dart_IsError(result)); | 3191 EXPECT(Dart_IsError(result)); |
| 3194 EXPECT_STREQ("Duplicate definition : 'foo' is defined in" | 3192 EXPECT_STREQ("Duplicate definition : 'foo' is defined in" |
| 3195 " 'library2.dart' and 'dart:test-lib'\n", | 3193 " 'library2.dart' and 'dart:test-lib'\n", |
| 3196 Dart_GetError(result)); | 3194 Dart_GetError(result)); |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3733 // We should have received the expected number of interrupts. | 3731 // We should have received the expected number of interrupts. |
| 3734 EXPECT_EQ(kInterruptCount, interrupt_count); | 3732 EXPECT_EQ(kInterruptCount, interrupt_count); |
| 3735 | 3733 |
| 3736 // Give the spawned thread enough time to properly exit. | 3734 // Give the spawned thread enough time to properly exit. |
| 3737 Isolate::SetInterruptCallback(saved); | 3735 Isolate::SetInterruptCallback(saved); |
| 3738 } | 3736 } |
| 3739 | 3737 |
| 3740 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 3738 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 3741 | 3739 |
| 3742 } // namespace dart | 3740 } // namespace dart |
| OLD | NEW |