| 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/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
| 10 #include "vm/thread.h" | 11 #include "vm/thread.h" |
| 11 #include "vm/unit_test.h" | 12 #include "vm/unit_test.h" |
| 12 #include "vm/verifier.h" | 13 #include "vm/verifier.h" |
| 13 | 14 |
| 14 namespace dart { | 15 namespace dart { |
| 15 | 16 |
| 16 // Only ia32 and x64 can run execution tests. | 17 // Only ia32 and x64 can run execution tests. |
| 17 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 18 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
| (...skipping 2159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2177 function_name2, | 2178 function_name2, |
| 2178 number_of_arguments, | 2179 number_of_arguments, |
| 2179 dart_arguments); | 2180 dart_arguments); |
| 2180 EXPECT(Dart_IsError(result)); | 2181 EXPECT(Dart_IsError(result)); |
| 2181 EXPECT(Dart_ErrorHasException(result)); */ | 2182 EXPECT(Dart_ErrorHasException(result)); */ |
| 2182 } | 2183 } |
| 2183 | 2184 |
| 2184 | 2185 |
| 2185 static Dart_Handle library_handler(Dart_LibraryTag tag, | 2186 static Dart_Handle library_handler(Dart_LibraryTag tag, |
| 2186 Dart_Handle library, | 2187 Dart_Handle library, |
| 2187 Dart_Handle url) { | 2188 Dart_Handle url, |
| 2189 Dart_Handle import_url_map) { |
| 2188 if (tag == kCanonicalizeUrl) { | 2190 if (tag == kCanonicalizeUrl) { |
| 2189 return url; | 2191 return url; |
| 2190 } | 2192 } |
| 2191 return Api::Success(); | 2193 return Api::Success(); |
| 2192 } | 2194 } |
| 2193 | 2195 |
| 2194 | 2196 |
| 2195 TEST_CASE(LoadScript) { | 2197 TEST_CASE(LoadScript) { |
| 2196 const char* kScriptChars = | 2198 const char* kScriptChars = |
| 2197 "main() {" | 2199 "main() {" |
| 2198 " return 12345;" | 2200 " return 12345;" |
| 2199 "}"; | 2201 "}"; |
| 2200 Dart_Handle url = Dart_NewString(TestCase::url()); | 2202 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 2201 Dart_Handle source = Dart_NewString(kScriptChars); | 2203 Dart_Handle source = Dart_NewString(kScriptChars); |
| 2202 Dart_Handle error = Dart_Error("incoming error"); | 2204 Dart_Handle error = Dart_Error("incoming error"); |
| 2203 Dart_Handle result; | 2205 Dart_Handle result; |
| 2206 Dart_Handle import_map = Dart_NewList(0); |
| 2204 | 2207 |
| 2205 result = Dart_LoadScript(Dart_Null(), source, library_handler); | 2208 result = Dart_LoadScript(Dart_Null(), source, library_handler, import_map); |
| 2206 EXPECT(Dart_IsError(result)); | 2209 EXPECT(Dart_IsError(result)); |
| 2207 EXPECT_STREQ("Dart_LoadScript expects argument 'url' to be non-null.", | 2210 EXPECT_STREQ("Dart_LoadScript expects argument 'url' to be non-null.", |
| 2208 Dart_GetError(result)); | 2211 Dart_GetError(result)); |
| 2209 | 2212 |
| 2210 result = Dart_LoadScript(Dart_True(), source, library_handler); | 2213 result = Dart_LoadScript(Dart_True(), source, library_handler, import_map); |
| 2211 EXPECT(Dart_IsError(result)); | 2214 EXPECT(Dart_IsError(result)); |
| 2212 EXPECT_STREQ("Dart_LoadScript expects argument 'url' to be of type String.", | 2215 EXPECT_STREQ("Dart_LoadScript expects argument 'url' to be of type String.", |
| 2213 Dart_GetError(result)); | 2216 Dart_GetError(result)); |
| 2214 | 2217 |
| 2215 result = Dart_LoadScript(error, source, library_handler); | 2218 result = Dart_LoadScript(error, source, library_handler, import_map); |
| 2216 EXPECT(Dart_IsError(result)); | 2219 EXPECT(Dart_IsError(result)); |
| 2217 EXPECT_STREQ("incoming error", Dart_GetError(result)); | 2220 EXPECT_STREQ("incoming error", Dart_GetError(result)); |
| 2218 | 2221 |
| 2219 result = Dart_LoadScript(url, Dart_Null(), library_handler); | 2222 result = Dart_LoadScript(url, Dart_Null(), library_handler, import_map); |
| 2220 EXPECT(Dart_IsError(result)); | 2223 EXPECT(Dart_IsError(result)); |
| 2221 EXPECT_STREQ("Dart_LoadScript expects argument 'source' to be non-null.", | 2224 EXPECT_STREQ("Dart_LoadScript expects argument 'source' to be non-null.", |
| 2222 Dart_GetError(result)); | 2225 Dart_GetError(result)); |
| 2223 | 2226 |
| 2224 result = Dart_LoadScript(url, Dart_True(), library_handler); | 2227 result = Dart_LoadScript(url, Dart_True(), library_handler, import_map); |
| 2225 EXPECT(Dart_IsError(result)); | 2228 EXPECT(Dart_IsError(result)); |
| 2226 EXPECT_STREQ( | 2229 EXPECT_STREQ( |
| 2227 "Dart_LoadScript expects argument 'source' to be of type String.", | 2230 "Dart_LoadScript expects argument 'source' to be of type String.", |
| 2228 Dart_GetError(result)); | 2231 Dart_GetError(result)); |
| 2229 | 2232 |
| 2230 result = Dart_LoadScript(url, error, library_handler); | 2233 result = Dart_LoadScript(url, error, library_handler, import_map); |
| 2231 EXPECT(Dart_IsError(result)); | 2234 EXPECT(Dart_IsError(result)); |
| 2232 EXPECT_STREQ("incoming error", Dart_GetError(result)); | 2235 EXPECT_STREQ("incoming error", Dart_GetError(result)); |
| 2233 | 2236 |
| 2234 // Load a script successfully. | 2237 // Load a script successfully. |
| 2235 result = Dart_LoadScript(url, source, library_handler); | 2238 result = Dart_LoadScript(url, source, library_handler, import_map); |
| 2236 EXPECT_VALID(result); | 2239 EXPECT_VALID(result); |
| 2237 | 2240 |
| 2238 result = Dart_InvokeStatic(result, | 2241 result = Dart_InvokeStatic(result, |
| 2239 Dart_NewString(""), | 2242 Dart_NewString(""), |
| 2240 Dart_NewString("main"), | 2243 Dart_NewString("main"), |
| 2241 0, | 2244 0, |
| 2242 NULL); | 2245 NULL); |
| 2243 EXPECT_VALID(result); | 2246 EXPECT_VALID(result); |
| 2244 EXPECT(Dart_IsInteger(result)); | 2247 EXPECT(Dart_IsInteger(result)); |
| 2245 int64_t value = 0; | 2248 int64_t value = 0; |
| 2246 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); | 2249 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); |
| 2247 EXPECT_EQ(12345, value); | 2250 EXPECT_EQ(12345, value); |
| 2248 | 2251 |
| 2249 // Further calls to LoadScript are errors. | 2252 // Further calls to LoadScript are errors. |
| 2250 result = Dart_LoadScript(url, source, library_handler); | 2253 result = Dart_LoadScript(url, source, library_handler, import_map); |
| 2251 EXPECT(Dart_IsError(result)); | 2254 EXPECT(Dart_IsError(result)); |
| 2252 EXPECT_STREQ("Dart_LoadScript: " | 2255 EXPECT_STREQ("Dart_LoadScript: " |
| 2253 "A script has already been loaded from 'dart:test-lib'.", | 2256 "A script has already been loaded from 'dart:test-lib'.", |
| 2254 Dart_GetError(result)); | 2257 Dart_GetError(result)); |
| 2255 } | 2258 } |
| 2256 | 2259 |
| 2257 | 2260 |
| 2261 static const char* var_mapping[] = { |
| 2262 "GOOGLE3", ".", |
| 2263 "ABC", "lala", |
| 2264 "var1", "", |
| 2265 "var2", "winner", |
| 2266 }; |
| 2267 static int index = 0; |
| 2268 |
| 2269 |
| 2270 static Dart_Handle import_library_handler(Dart_LibraryTag tag, |
| 2271 Dart_Handle library, |
| 2272 Dart_Handle url, |
| 2273 Dart_Handle import_url_map) { |
| 2274 if (tag == kCanonicalizeUrl) { |
| 2275 return url; |
| 2276 } |
| 2277 EXPECT(Dart_IsString(url)); |
| 2278 const char* cstr = NULL; |
| 2279 EXPECT_VALID(Dart_StringToCString(url, &cstr)); |
| 2280 switch (index) { |
| 2281 case 0: |
| 2282 EXPECT_STREQ("./weird.dart", cstr); |
| 2283 break; |
| 2284 case 1: |
| 2285 EXPECT_STREQ("abclaladef", cstr); |
| 2286 break; |
| 2287 case 2: |
| 2288 EXPECT_STREQ("winner", cstr); |
| 2289 break; |
| 2290 case 3: |
| 2291 EXPECT_STREQ("abclaladef/extra_weird.dart", cstr); |
| 2292 break; |
| 2293 case 4: |
| 2294 EXPECT_STREQ("winnerwinner", cstr); |
| 2295 break; |
| 2296 default: |
| 2297 EXPECT(false); |
| 2298 return Api::NewError("invalid callback"); |
| 2299 } |
| 2300 index += 1; |
| 2301 return Api::Success(); |
| 2302 } |
| 2303 |
| 2304 |
| 2305 TEST_CASE(LoadImportScript) { |
| 2306 const char* kScriptChars = |
| 2307 "#import('$GOOGLE3/weird.dart');" |
| 2308 "#import('abc${ABC}def');" |
| 2309 "#import('${var1}$var2');" |
| 2310 "#import('abc${ABC}def/extra_weird.dart');" |
| 2311 "#import('$var2$var2');" |
| 2312 "main() {" |
| 2313 " return 12345;" |
| 2314 "}"; |
| 2315 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 2316 Dart_Handle source = Dart_NewString(kScriptChars); |
| 2317 intptr_t length = (sizeof(var_mapping) / sizeof(var_mapping[0])); |
| 2318 Dart_Handle import_map = Dart_NewList(length); |
| 2319 for (intptr_t i = 0; i < length; i++) { |
| 2320 Dart_ListSetAt(import_map, i, Dart_NewString(var_mapping[i])); |
| 2321 } |
| 2322 Dart_Handle result = Dart_LoadScript(url, |
| 2323 source, |
| 2324 import_library_handler, |
| 2325 import_map); |
| 2326 EXPECT(!Dart_IsError(result)); |
| 2327 } |
| 2328 |
| 2329 |
| 2330 TEST_CASE(LoadImportScriptError1) { |
| 2331 const char* kScriptChars = |
| 2332 "#import('abc${DEF}def/extra_weird.dart');" |
| 2333 "main() {" |
| 2334 " return 12345;" |
| 2335 "}"; |
| 2336 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 2337 Dart_Handle source = Dart_NewString(kScriptChars); |
| 2338 Dart_Handle import_map = Dart_NewList(0); |
| 2339 Dart_Handle result = Dart_LoadScript(url, |
| 2340 source, |
| 2341 import_library_handler, |
| 2342 import_map); |
| 2343 EXPECT(Dart_IsError(result)); |
| 2344 EXPECT(strstr(Dart_GetError(result), |
| 2345 "import variable 'DEF' has not been defined")); |
| 2346 } |
| 2347 |
| 2348 |
| 2349 TEST_CASE(LoadImportScriptError2) { |
| 2350 const char* kScriptChars = |
| 2351 "#import('abc${ABC/extra_weird.dart');" |
| 2352 "main() {" |
| 2353 " return 12345;" |
| 2354 "}"; |
| 2355 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 2356 Dart_Handle source = Dart_NewString(kScriptChars); |
| 2357 intptr_t length = (sizeof(var_mapping) / sizeof(var_mapping[0])); |
| 2358 Dart_Handle import_map = Dart_NewList(length); |
| 2359 for (intptr_t i = 0; i < length; i++) { |
| 2360 Dart_ListSetAt(import_map, i, Dart_NewString(var_mapping[i])); |
| 2361 } |
| 2362 Dart_Handle result = Dart_LoadScript(url, |
| 2363 source, |
| 2364 import_library_handler, |
| 2365 import_map); |
| 2366 EXPECT(Dart_IsError(result)); |
| 2367 EXPECT(strstr(Dart_GetError(result), "'}' expected")); |
| 2368 } |
| 2369 |
| 2370 |
| 2258 TEST_CASE(LoadScript_CompileError) { | 2371 TEST_CASE(LoadScript_CompileError) { |
| 2259 const char* kScriptChars = | 2372 const char* kScriptChars = |
| 2260 ")"; | 2373 ")"; |
| 2261 Dart_Handle url = Dart_NewString(TestCase::url()); | 2374 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 2262 Dart_Handle source = Dart_NewString(kScriptChars); | 2375 Dart_Handle source = Dart_NewString(kScriptChars); |
| 2263 Dart_Handle result = Dart_LoadScript(url, source, library_handler); | 2376 Dart_Handle import_map = Dart_NewList(0); |
| 2377 Dart_Handle result = Dart_LoadScript(url, |
| 2378 source, |
| 2379 library_handler, |
| 2380 import_map); |
| 2264 EXPECT(Dart_IsError(result)); | 2381 EXPECT(Dart_IsError(result)); |
| 2265 EXPECT(strstr(Dart_GetError(result), "unexpected token ')'")); | 2382 EXPECT(strstr(Dart_GetError(result), "unexpected token ')'")); |
| 2266 } | 2383 } |
| 2267 | 2384 |
| 2268 | 2385 |
| 2269 TEST_CASE(LookupLibrary) { | 2386 TEST_CASE(LookupLibrary) { |
| 2270 const char* kScriptChars = | 2387 const char* kScriptChars = |
| 2271 "#import('library1.dart');" | 2388 "#import('library1.dart');" |
| 2272 "main() {}"; | 2389 "main() {}"; |
| 2273 const char* kLibrary1Chars = | 2390 const char* kLibrary1Chars = |
| 2274 "#library('library1.dart');" | 2391 "#library('library1.dart');" |
| 2275 "#import('library2.dart');"; | 2392 "#import('library2.dart');"; |
| 2276 | 2393 |
| 2277 // Create a test library and Load up a test script in it. | 2394 // Create a test library and Load up a test script in it. |
| 2278 Dart_Handle url = Dart_NewString(TestCase::url()); | 2395 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 2279 Dart_Handle source = Dart_NewString(kScriptChars); | 2396 Dart_Handle source = Dart_NewString(kScriptChars); |
| 2280 Dart_Handle result = Dart_LoadScript(url, source, library_handler); | 2397 Dart_Handle import_map = Dart_NewList(0); |
| 2398 Dart_Handle result = Dart_LoadScript(url, |
| 2399 source, |
| 2400 library_handler, |
| 2401 import_map); |
| 2281 EXPECT_VALID(result); | 2402 EXPECT_VALID(result); |
| 2282 | 2403 |
| 2283 url = Dart_NewString("library1.dart"); | 2404 url = Dart_NewString("library1.dart"); |
| 2284 source = Dart_NewString(kLibrary1Chars); | 2405 source = Dart_NewString(kLibrary1Chars); |
| 2285 result = Dart_LoadLibrary(url, source); | 2406 result = Dart_LoadLibrary(url, source, import_map); |
| 2286 EXPECT_VALID(result); | 2407 EXPECT_VALID(result); |
| 2287 | 2408 |
| 2288 result = Dart_LookupLibrary(url); | 2409 result = Dart_LookupLibrary(url); |
| 2289 EXPECT_VALID(result); | 2410 EXPECT_VALID(result); |
| 2290 | 2411 |
| 2291 result = Dart_LookupLibrary(Dart_Null()); | 2412 result = Dart_LookupLibrary(Dart_Null()); |
| 2292 EXPECT(Dart_IsError(result)); | 2413 EXPECT(Dart_IsError(result)); |
| 2293 EXPECT_STREQ("Dart_LookupLibrary expects argument 'url' to be non-null.", | 2414 EXPECT_STREQ("Dart_LookupLibrary expects argument 'url' to be non-null.", |
| 2294 Dart_GetError(result)); | 2415 Dart_GetError(result)); |
| 2295 | 2416 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2309 EXPECT_STREQ("Dart_LookupLibrary: library 'noodles.dart' not found.", | 2430 EXPECT_STREQ("Dart_LookupLibrary: library 'noodles.dart' not found.", |
| 2310 Dart_GetError(result)); | 2431 Dart_GetError(result)); |
| 2311 } | 2432 } |
| 2312 | 2433 |
| 2313 | 2434 |
| 2314 TEST_CASE(LibraryUrl) { | 2435 TEST_CASE(LibraryUrl) { |
| 2315 const char* kLibrary1Chars = | 2436 const char* kLibrary1Chars = |
| 2316 "#library('library1_name');"; | 2437 "#library('library1_name');"; |
| 2317 Dart_Handle url = Dart_NewString("library1_url"); | 2438 Dart_Handle url = Dart_NewString("library1_url"); |
| 2318 Dart_Handle source = Dart_NewString(kLibrary1Chars); | 2439 Dart_Handle source = Dart_NewString(kLibrary1Chars); |
| 2319 Dart_Handle lib = Dart_LoadLibrary(url, source); | 2440 Dart_Handle import_map = Dart_NewList(0); |
| 2441 Dart_Handle lib = Dart_LoadLibrary(url, source, import_map); |
| 2320 Dart_Handle error = Dart_Error("incoming error"); | 2442 Dart_Handle error = Dart_Error("incoming error"); |
| 2321 EXPECT_VALID(lib); | 2443 EXPECT_VALID(lib); |
| 2322 | 2444 |
| 2323 Dart_Handle result = Dart_LibraryUrl(Dart_Null()); | 2445 Dart_Handle result = Dart_LibraryUrl(Dart_Null()); |
| 2324 EXPECT(Dart_IsError(result)); | 2446 EXPECT(Dart_IsError(result)); |
| 2325 EXPECT_STREQ("Dart_LibraryUrl expects argument 'library' to be non-null.", | 2447 EXPECT_STREQ("Dart_LibraryUrl expects argument 'library' to be non-null.", |
| 2326 Dart_GetError(result)); | 2448 Dart_GetError(result)); |
| 2327 | 2449 |
| 2328 result = Dart_LibraryUrl(Dart_True()); | 2450 result = Dart_LibraryUrl(Dart_True()); |
| 2329 EXPECT(Dart_IsError(result)); | 2451 EXPECT(Dart_IsError(result)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2347 TEST_CASE(LibraryImportLibrary) { | 2469 TEST_CASE(LibraryImportLibrary) { |
| 2348 const char* kLibrary1Chars = | 2470 const char* kLibrary1Chars = |
| 2349 "#library('library1_name');"; | 2471 "#library('library1_name');"; |
| 2350 const char* kLibrary2Chars = | 2472 const char* kLibrary2Chars = |
| 2351 "#library('library2_name');"; | 2473 "#library('library2_name');"; |
| 2352 Dart_Handle error = Dart_Error("incoming error"); | 2474 Dart_Handle error = Dart_Error("incoming error"); |
| 2353 Dart_Handle result; | 2475 Dart_Handle result; |
| 2354 | 2476 |
| 2355 Dart_Handle url = Dart_NewString("library1_url"); | 2477 Dart_Handle url = Dart_NewString("library1_url"); |
| 2356 Dart_Handle source = Dart_NewString(kLibrary1Chars); | 2478 Dart_Handle source = Dart_NewString(kLibrary1Chars); |
| 2357 Dart_Handle lib1 = Dart_LoadLibrary(url, source); | 2479 Dart_Handle import_map = Dart_NewList(0); |
| 2480 Dart_Handle lib1 = Dart_LoadLibrary(url, source, import_map); |
| 2358 EXPECT_VALID(lib1); | 2481 EXPECT_VALID(lib1); |
| 2359 | 2482 |
| 2360 url = Dart_NewString("library2_url"); | 2483 url = Dart_NewString("library2_url"); |
| 2361 source = Dart_NewString(kLibrary2Chars); | 2484 source = Dart_NewString(kLibrary2Chars); |
| 2362 Dart_Handle lib2 = Dart_LoadLibrary(url, source); | 2485 Dart_Handle lib2 = Dart_LoadLibrary(url, source, import_map); |
| 2363 EXPECT_VALID(lib2); | 2486 EXPECT_VALID(lib2); |
| 2364 | 2487 |
| 2365 result = Dart_LibraryImportLibrary(Dart_Null(), lib2); | 2488 result = Dart_LibraryImportLibrary(Dart_Null(), lib2); |
| 2366 EXPECT(Dart_IsError(result)); | 2489 EXPECT(Dart_IsError(result)); |
| 2367 EXPECT_STREQ( | 2490 EXPECT_STREQ( |
| 2368 "Dart_LibraryImportLibrary expects argument 'library' to be non-null.", | 2491 "Dart_LibraryImportLibrary expects argument 'library' to be non-null.", |
| 2369 Dart_GetError(result)); | 2492 Dart_GetError(result)); |
| 2370 | 2493 |
| 2371 result = Dart_LibraryImportLibrary(Dart_True(), lib2); | 2494 result = Dart_LibraryImportLibrary(Dart_True(), lib2); |
| 2372 EXPECT(Dart_IsError(result)); | 2495 EXPECT(Dart_IsError(result)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2401 | 2524 |
| 2402 | 2525 |
| 2403 TEST_CASE(LoadLibrary) { | 2526 TEST_CASE(LoadLibrary) { |
| 2404 const char* kLibrary1Chars = | 2527 const char* kLibrary1Chars = |
| 2405 "#library('library1_name');"; | 2528 "#library('library1_name');"; |
| 2406 Dart_Handle error = Dart_Error("incoming error"); | 2529 Dart_Handle error = Dart_Error("incoming error"); |
| 2407 Dart_Handle result; | 2530 Dart_Handle result; |
| 2408 | 2531 |
| 2409 Dart_Handle url = Dart_NewString("library1_url"); | 2532 Dart_Handle url = Dart_NewString("library1_url"); |
| 2410 Dart_Handle source = Dart_NewString(kLibrary1Chars); | 2533 Dart_Handle source = Dart_NewString(kLibrary1Chars); |
| 2534 Dart_Handle import_map = Dart_NewList(0); |
| 2411 | 2535 |
| 2412 result = Dart_LoadLibrary(Dart_Null(), source); | 2536 result = Dart_LoadLibrary(Dart_Null(), source, import_map); |
| 2413 EXPECT(Dart_IsError(result)); | 2537 EXPECT(Dart_IsError(result)); |
| 2414 EXPECT_STREQ("Dart_LoadLibrary expects argument 'url' to be non-null.", | 2538 EXPECT_STREQ("Dart_LoadLibrary expects argument 'url' to be non-null.", |
| 2415 Dart_GetError(result)); | 2539 Dart_GetError(result)); |
| 2416 | 2540 |
| 2417 result = Dart_LoadLibrary(Dart_True(), source); | 2541 result = Dart_LoadLibrary(Dart_True(), source, import_map); |
| 2418 EXPECT(Dart_IsError(result)); | 2542 EXPECT(Dart_IsError(result)); |
| 2419 EXPECT_STREQ("Dart_LoadLibrary expects argument 'url' to be of type String.", | 2543 EXPECT_STREQ("Dart_LoadLibrary expects argument 'url' to be of type String.", |
| 2420 Dart_GetError(result)); | 2544 Dart_GetError(result)); |
| 2421 | 2545 |
| 2422 result = Dart_LoadLibrary(error, source); | 2546 result = Dart_LoadLibrary(error, source, import_map); |
| 2423 EXPECT(Dart_IsError(result)); | 2547 EXPECT(Dart_IsError(result)); |
| 2424 EXPECT_STREQ("incoming error", Dart_GetError(result)); | 2548 EXPECT_STREQ("incoming error", Dart_GetError(result)); |
| 2425 | 2549 |
| 2426 result = Dart_LoadLibrary(url, Dart_Null()); | 2550 result = Dart_LoadLibrary(url, Dart_Null(), import_map); |
| 2427 EXPECT(Dart_IsError(result)); | 2551 EXPECT(Dart_IsError(result)); |
| 2428 EXPECT_STREQ("Dart_LoadLibrary expects argument 'source' to be non-null.", | 2552 EXPECT_STREQ("Dart_LoadLibrary expects argument 'source' to be non-null.", |
| 2429 Dart_GetError(result)); | 2553 Dart_GetError(result)); |
| 2430 | 2554 |
| 2431 result = Dart_LoadLibrary(url, Dart_True()); | 2555 result = Dart_LoadLibrary(url, Dart_True(), import_map); |
| 2432 EXPECT(Dart_IsError(result)); | 2556 EXPECT(Dart_IsError(result)); |
| 2433 EXPECT_STREQ( | 2557 EXPECT_STREQ( |
| 2434 "Dart_LoadLibrary expects argument 'source' to be of type String.", | 2558 "Dart_LoadLibrary expects argument 'source' to be of type String.", |
| 2435 Dart_GetError(result)); | 2559 Dart_GetError(result)); |
| 2436 | 2560 |
| 2437 result = Dart_LoadLibrary(url, error); | 2561 result = Dart_LoadLibrary(url, error, import_map); |
| 2438 EXPECT(Dart_IsError(result)); | 2562 EXPECT(Dart_IsError(result)); |
| 2439 EXPECT_STREQ("incoming error", Dart_GetError(result)); | 2563 EXPECT_STREQ("incoming error", Dart_GetError(result)); |
| 2440 | 2564 |
| 2441 // Success. | 2565 // Success. |
| 2442 result = Dart_LoadLibrary(url, source); | 2566 result = Dart_LoadLibrary(url, source, import_map); |
| 2443 EXPECT_VALID(result); | 2567 EXPECT_VALID(result); |
| 2444 EXPECT(Dart_IsLibrary(result)); | 2568 EXPECT(Dart_IsLibrary(result)); |
| 2445 | 2569 |
| 2446 // Duplicate library load fails. | 2570 // Duplicate library load fails. |
| 2447 result = Dart_LoadLibrary(url, source); | 2571 result = Dart_LoadLibrary(url, source, import_map); |
| 2448 EXPECT(Dart_IsError(result)); | 2572 EXPECT(Dart_IsError(result)); |
| 2449 EXPECT_STREQ( | 2573 EXPECT_STREQ( |
| 2450 "Dart_LoadLibrary: library 'library1_url' has already been loaded.", | 2574 "Dart_LoadLibrary: library 'library1_url' has already been loaded.", |
| 2451 Dart_GetError(result)); | 2575 Dart_GetError(result)); |
| 2452 } | 2576 } |
| 2453 | 2577 |
| 2454 | 2578 |
| 2455 TEST_CASE(LoadLibrary_CompileError) { | 2579 TEST_CASE(LoadLibrary_CompileError) { |
| 2456 const char* kLibrary1Chars = | 2580 const char* kLibrary1Chars = |
| 2457 "#library('library1_name');" | 2581 "#library('library1_name');" |
| 2458 ")"; | 2582 ")"; |
| 2459 Dart_Handle url = Dart_NewString("library1_url"); | 2583 Dart_Handle url = Dart_NewString("library1_url"); |
| 2460 Dart_Handle source = Dart_NewString(kLibrary1Chars); | 2584 Dart_Handle source = Dart_NewString(kLibrary1Chars); |
| 2461 Dart_Handle result = Dart_LoadLibrary(url, source); | 2585 Dart_Handle import_map = Dart_NewList(0); |
| 2586 Dart_Handle result = Dart_LoadLibrary(url, source, import_map); |
| 2462 EXPECT(Dart_IsError(result)); | 2587 EXPECT(Dart_IsError(result)); |
| 2463 EXPECT(strstr(Dart_GetError(result), "unexpected token ')'")); | 2588 EXPECT(strstr(Dart_GetError(result), "unexpected token ')'")); |
| 2464 } | 2589 } |
| 2465 | 2590 |
| 2466 | 2591 |
| 2467 TEST_CASE(LoadSource) { | 2592 TEST_CASE(LoadSource) { |
| 2468 const char* kLibrary1Chars = | 2593 const char* kLibrary1Chars = |
| 2469 "#library('library1_name');"; | 2594 "#library('library1_name');"; |
| 2470 const char* kSourceChars = | 2595 const char* kSourceChars = |
| 2471 "// Something innocuous"; | 2596 "// Something innocuous"; |
| 2472 const char* kBadSourceChars = | 2597 const char* kBadSourceChars = |
| 2473 ")"; | 2598 ")"; |
| 2474 Dart_Handle error = Dart_Error("incoming error"); | 2599 Dart_Handle error = Dart_Error("incoming error"); |
| 2475 Dart_Handle result; | 2600 Dart_Handle result; |
| 2476 | 2601 |
| 2477 // Load up a library. | 2602 // Load up a library. |
| 2478 Dart_Handle url = Dart_NewString("library1_url"); | 2603 Dart_Handle url = Dart_NewString("library1_url"); |
| 2479 Dart_Handle source = Dart_NewString(kLibrary1Chars); | 2604 Dart_Handle source = Dart_NewString(kLibrary1Chars); |
| 2480 Dart_Handle lib = Dart_LoadLibrary(url, source); | 2605 Dart_Handle import_map = Dart_NewList(0); |
| 2606 Dart_Handle lib = Dart_LoadLibrary(url, source, import_map); |
| 2481 EXPECT_VALID(lib); | 2607 EXPECT_VALID(lib); |
| 2482 EXPECT(Dart_IsLibrary(lib)); | 2608 EXPECT(Dart_IsLibrary(lib)); |
| 2483 | 2609 |
| 2484 url = Dart_NewString("source_url"); | 2610 url = Dart_NewString("source_url"); |
| 2485 source = Dart_NewString(kSourceChars); | 2611 source = Dart_NewString(kSourceChars); |
| 2486 | 2612 |
| 2487 result = Dart_LoadSource(Dart_Null(), url, source); | 2613 result = Dart_LoadSource(Dart_Null(), url, source); |
| 2488 EXPECT(Dart_IsError(result)); | 2614 EXPECT(Dart_IsError(result)); |
| 2489 EXPECT_STREQ("Dart_LoadSource expects argument 'library' to be non-null.", | 2615 EXPECT_STREQ("Dart_LoadSource expects argument 'library' to be non-null.", |
| 2490 Dart_GetError(result)); | 2616 Dart_GetError(result)); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2583 " static foo() native \"SomeNativeFunction\";" | 2709 " static foo() native \"SomeNativeFunction\";" |
| 2584 " static bar() native \"SomeNativeFunction2\";" | 2710 " static bar() native \"SomeNativeFunction2\";" |
| 2585 " static baz() native \"SomeNativeFunction3\";" | 2711 " static baz() native \"SomeNativeFunction3\";" |
| 2586 "}"; | 2712 "}"; |
| 2587 Dart_Handle error = Dart_Error("incoming error"); | 2713 Dart_Handle error = Dart_Error("incoming error"); |
| 2588 Dart_Handle result; | 2714 Dart_Handle result; |
| 2589 | 2715 |
| 2590 // Load a test script. | 2716 // Load a test script. |
| 2591 Dart_Handle url = Dart_NewString(TestCase::url()); | 2717 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 2592 Dart_Handle source = Dart_NewString(kScriptChars); | 2718 Dart_Handle source = Dart_NewString(kScriptChars); |
| 2593 Dart_Handle lib = Dart_LoadScript(url, source, library_handler); | 2719 Dart_Handle import_map = Dart_NewList(0); |
| 2720 Dart_Handle lib = Dart_LoadScript(url, source, library_handler, import_map); |
| 2594 EXPECT_VALID(lib); | 2721 EXPECT_VALID(lib); |
| 2595 EXPECT(Dart_IsLibrary(lib)); | 2722 EXPECT(Dart_IsLibrary(lib)); |
| 2596 | 2723 |
| 2597 result = Dart_SetNativeResolver(Dart_Null(), &MyNativeResolver1); | 2724 result = Dart_SetNativeResolver(Dart_Null(), &MyNativeResolver1); |
| 2598 EXPECT(Dart_IsError(result)); | 2725 EXPECT(Dart_IsError(result)); |
| 2599 EXPECT_STREQ( | 2726 EXPECT_STREQ( |
| 2600 "Dart_SetNativeResolver expects argument 'library' to be non-null.", | 2727 "Dart_SetNativeResolver expects argument 'library' to be non-null.", |
| 2601 Dart_GetError(result)); | 2728 Dart_GetError(result)); |
| 2602 | 2729 |
| 2603 result = Dart_SetNativeResolver(Dart_True(), &MyNativeResolver1); | 2730 result = Dart_SetNativeResolver(Dart_True(), &MyNativeResolver1); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2678 "#library('library1.dart');" | 2805 "#library('library1.dart');" |
| 2679 "#import('library2.dart');" | 2806 "#import('library2.dart');" |
| 2680 "var foo1;"; | 2807 "var foo1;"; |
| 2681 const char* kLibrary2Chars = | 2808 const char* kLibrary2Chars = |
| 2682 "#library('library2.dart');" | 2809 "#library('library2.dart');" |
| 2683 "var foo;"; | 2810 "var foo;"; |
| 2684 Dart_Handle result; | 2811 Dart_Handle result; |
| 2685 // Create a test library and Load up a test script in it. | 2812 // Create a test library and Load up a test script in it. |
| 2686 Dart_Handle url = Dart_NewString(TestCase::url()); | 2813 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 2687 Dart_Handle source = Dart_NewString(kScriptChars); | 2814 Dart_Handle source = Dart_NewString(kScriptChars); |
| 2688 result = Dart_LoadScript(url, source, library_handler); | 2815 Dart_Handle import_map = Dart_NewList(0); |
| 2816 result = Dart_LoadScript(url, source, library_handler, import_map); |
| 2689 | 2817 |
| 2690 url = Dart_NewString("library1.dart"); | 2818 url = Dart_NewString("library1.dart"); |
| 2691 source = Dart_NewString(kLibrary1Chars); | 2819 source = Dart_NewString(kLibrary1Chars); |
| 2692 Dart_LoadLibrary(url, source); | 2820 Dart_LoadLibrary(url, source, import_map); |
| 2693 | 2821 |
| 2694 url = Dart_NewString("library2.dart"); | 2822 url = Dart_NewString("library2.dart"); |
| 2695 source = Dart_NewString(kLibrary2Chars); | 2823 source = Dart_NewString(kLibrary2Chars); |
| 2696 Dart_LoadLibrary(url, source); | 2824 Dart_LoadLibrary(url, source, import_map); |
| 2697 | 2825 |
| 2698 result = Dart_InvokeStatic(result, | 2826 result = Dart_InvokeStatic(result, |
| 2699 Dart_NewString(""), | 2827 Dart_NewString(""), |
| 2700 Dart_NewString("main"), | 2828 Dart_NewString("main"), |
| 2701 0, | 2829 0, |
| 2702 NULL); | 2830 NULL); |
| 2703 EXPECT(Dart_IsError(result)); | 2831 EXPECT(Dart_IsError(result)); |
| 2704 EXPECT_STREQ("Duplicate definition : 'foo' is defined in" | 2832 EXPECT_STREQ("Duplicate definition : 'foo' is defined in" |
| 2705 " 'library2.dart' and 'dart:test-lib'\n", | 2833 " 'library2.dart' and 'dart:test-lib'\n", |
| 2706 Dart_GetError(result)); | 2834 Dart_GetError(result)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2717 "#import('library2.dart');" | 2845 "#import('library2.dart');" |
| 2718 "var foo1;"; | 2846 "var foo1;"; |
| 2719 const char* kLibrary2Chars = | 2847 const char* kLibrary2Chars = |
| 2720 "#library('library2.dart');" | 2848 "#library('library2.dart');" |
| 2721 "#import('library1.dart');" | 2849 "#import('library1.dart');" |
| 2722 "var foo;"; | 2850 "var foo;"; |
| 2723 Dart_Handle result; | 2851 Dart_Handle result; |
| 2724 // Create a test library and Load up a test script in it. | 2852 // Create a test library and Load up a test script in it. |
| 2725 Dart_Handle url = Dart_NewString(TestCase::url()); | 2853 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 2726 Dart_Handle source = Dart_NewString(kScriptChars); | 2854 Dart_Handle source = Dart_NewString(kScriptChars); |
| 2727 result = Dart_LoadScript(url, source, library_handler); | 2855 Dart_Handle import_map = Dart_NewList(0); |
| 2856 result = Dart_LoadScript(url, source, library_handler, import_map); |
| 2728 | 2857 |
| 2729 url = Dart_NewString("library1.dart"); | 2858 url = Dart_NewString("library1.dart"); |
| 2730 source = Dart_NewString(kLibrary1Chars); | 2859 source = Dart_NewString(kLibrary1Chars); |
| 2731 Dart_LoadLibrary(url, source); | 2860 Dart_LoadLibrary(url, source, import_map); |
| 2732 | 2861 |
| 2733 url = Dart_NewString("library2.dart"); | 2862 url = Dart_NewString("library2.dart"); |
| 2734 source = Dart_NewString(kLibrary2Chars); | 2863 source = Dart_NewString(kLibrary2Chars); |
| 2735 Dart_LoadLibrary(url, source); | 2864 Dart_LoadLibrary(url, source, import_map); |
| 2736 | 2865 |
| 2737 result = Dart_InvokeStatic(result, | 2866 result = Dart_InvokeStatic(result, |
| 2738 Dart_NewString(""), | 2867 Dart_NewString(""), |
| 2739 Dart_NewString("main"), | 2868 Dart_NewString("main"), |
| 2740 0, | 2869 0, |
| 2741 NULL); | 2870 NULL); |
| 2742 EXPECT_VALID(result); | 2871 EXPECT_VALID(result); |
| 2743 } | 2872 } |
| 2744 | 2873 |
| 2745 | 2874 |
| 2746 TEST_CASE(ImportLibrary3) { | 2875 TEST_CASE(ImportLibrary3) { |
| 2747 const char* kScriptChars = | 2876 const char* kScriptChars = |
| 2748 "#import('library2.dart');" | 2877 "#import('library2.dart');" |
| 2749 "#import('library1.dart');" | 2878 "#import('library1.dart');" |
| 2750 "var foo_top = 10; // foo has dup def. So should be an error." | 2879 "var foo_top = 10; // foo has dup def. So should be an error." |
| 2751 "main() {}"; | 2880 "main() {}"; |
| 2752 const char* kLibrary1Chars = | 2881 const char* kLibrary1Chars = |
| 2753 "#library('library1.dart');" | 2882 "#library('library1.dart');" |
| 2754 "var foo;"; | 2883 "var foo;"; |
| 2755 const char* kLibrary2Chars = | 2884 const char* kLibrary2Chars = |
| 2756 "#library('library2.dart');" | 2885 "#library('library2.dart');" |
| 2757 "var foo;"; | 2886 "var foo;"; |
| 2758 Dart_Handle result; | 2887 Dart_Handle result; |
| 2759 | 2888 |
| 2760 // Create a test library and Load up a test script in it. | 2889 // Create a test library and Load up a test script in it. |
| 2761 Dart_Handle url = Dart_NewString(TestCase::url()); | 2890 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 2762 Dart_Handle source = Dart_NewString(kScriptChars); | 2891 Dart_Handle source = Dart_NewString(kScriptChars); |
| 2763 result = Dart_LoadScript(url, source, library_handler); | 2892 Dart_Handle import_map = Dart_NewList(0); |
| 2893 result = Dart_LoadScript(url, source, library_handler, import_map); |
| 2764 | 2894 |
| 2765 url = Dart_NewString("library2.dart"); | 2895 url = Dart_NewString("library2.dart"); |
| 2766 source = Dart_NewString(kLibrary2Chars); | 2896 source = Dart_NewString(kLibrary2Chars); |
| 2767 Dart_LoadLibrary(url, source); | 2897 Dart_LoadLibrary(url, source, import_map); |
| 2768 | 2898 |
| 2769 url = Dart_NewString("library1.dart"); | 2899 url = Dart_NewString("library1.dart"); |
| 2770 source = Dart_NewString(kLibrary1Chars); | 2900 source = Dart_NewString(kLibrary1Chars); |
| 2771 Dart_LoadLibrary(url, source); | 2901 Dart_LoadLibrary(url, source, import_map); |
| 2772 | 2902 |
| 2773 result = Dart_InvokeStatic(result, | 2903 result = Dart_InvokeStatic(result, |
| 2774 Dart_NewString(""), | 2904 Dart_NewString(""), |
| 2775 Dart_NewString("main"), | 2905 Dart_NewString("main"), |
| 2776 0, | 2906 0, |
| 2777 NULL); | 2907 NULL); |
| 2778 EXPECT(Dart_IsError(result)); | 2908 EXPECT(Dart_IsError(result)); |
| 2779 EXPECT_STREQ("Duplicate definition : 'foo' is defined in" | 2909 EXPECT_STREQ("Duplicate definition : 'foo' is defined in" |
| 2780 " 'library1.dart' and 'library2.dart'\n", | 2910 " 'library1.dart' and 'library2.dart'\n", |
| 2781 Dart_GetError(result)); | 2911 Dart_GetError(result)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2811 "#import('libraryF.dart');" | 2941 "#import('libraryF.dart');" |
| 2812 "var fooE = 10; //fooC has duplicate def. so should be an error."; | 2942 "var fooE = 10; //fooC has duplicate def. so should be an error."; |
| 2813 const char* kLibraryFChars = | 2943 const char* kLibraryFChars = |
| 2814 "#library('libraryF.dart');" | 2944 "#library('libraryF.dart');" |
| 2815 "var fooC;"; | 2945 "var fooC;"; |
| 2816 Dart_Handle result; | 2946 Dart_Handle result; |
| 2817 | 2947 |
| 2818 // Create a test library and Load up a test script in it. | 2948 // Create a test library and Load up a test script in it. |
| 2819 Dart_Handle url = Dart_NewString(TestCase::url()); | 2949 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 2820 Dart_Handle source = Dart_NewString(kScriptChars); | 2950 Dart_Handle source = Dart_NewString(kScriptChars); |
| 2821 result = Dart_LoadScript(url, source, library_handler); | 2951 Dart_Handle import_map = Dart_NewList(0); |
| 2952 result = Dart_LoadScript(url, source, library_handler, import_map); |
| 2822 | 2953 |
| 2823 url = Dart_NewString("libraryA.dart"); | 2954 url = Dart_NewString("libraryA.dart"); |
| 2824 source = Dart_NewString(kLibraryAChars); | 2955 source = Dart_NewString(kLibraryAChars); |
| 2825 Dart_LoadLibrary(url, source); | 2956 Dart_LoadLibrary(url, source, import_map); |
| 2826 | 2957 |
| 2827 url = Dart_NewString("libraryC.dart"); | 2958 url = Dart_NewString("libraryC.dart"); |
| 2828 source = Dart_NewString(kLibraryCChars); | 2959 source = Dart_NewString(kLibraryCChars); |
| 2829 Dart_LoadLibrary(url, source); | 2960 Dart_LoadLibrary(url, source, import_map); |
| 2830 | 2961 |
| 2831 url = Dart_NewString("libraryB.dart"); | 2962 url = Dart_NewString("libraryB.dart"); |
| 2832 source = Dart_NewString(kLibraryBChars); | 2963 source = Dart_NewString(kLibraryBChars); |
| 2833 Dart_LoadLibrary(url, source); | 2964 Dart_LoadLibrary(url, source, import_map); |
| 2834 | 2965 |
| 2835 url = Dart_NewString("libraryD.dart"); | 2966 url = Dart_NewString("libraryD.dart"); |
| 2836 source = Dart_NewString(kLibraryDChars); | 2967 source = Dart_NewString(kLibraryDChars); |
| 2837 Dart_LoadLibrary(url, source); | 2968 Dart_LoadLibrary(url, source, import_map); |
| 2838 | 2969 |
| 2839 url = Dart_NewString("libraryF.dart"); | 2970 url = Dart_NewString("libraryF.dart"); |
| 2840 source = Dart_NewString(kLibraryFChars); | 2971 source = Dart_NewString(kLibraryFChars); |
| 2841 Dart_LoadLibrary(url, source); | 2972 Dart_LoadLibrary(url, source, import_map); |
| 2842 | 2973 |
| 2843 url = Dart_NewString("libraryE.dart"); | 2974 url = Dart_NewString("libraryE.dart"); |
| 2844 source = Dart_NewString(kLibraryEChars); | 2975 source = Dart_NewString(kLibraryEChars); |
| 2845 Dart_LoadLibrary(url, source); | 2976 Dart_LoadLibrary(url, source, import_map); |
| 2846 | 2977 |
| 2847 result = Dart_InvokeStatic(result, | 2978 result = Dart_InvokeStatic(result, |
| 2848 Dart_NewString(""), | 2979 Dart_NewString(""), |
| 2849 Dart_NewString("main"), | 2980 Dart_NewString("main"), |
| 2850 0, | 2981 0, |
| 2851 NULL); | 2982 NULL); |
| 2852 EXPECT(Dart_IsError(result)); | 2983 EXPECT(Dart_IsError(result)); |
| 2853 EXPECT_STREQ("Duplicate definition : 'fooC' is defined in" | 2984 EXPECT_STREQ("Duplicate definition : 'fooC' is defined in" |
| 2854 " 'libraryF.dart' and 'libraryC.dart'\n", | 2985 " 'libraryF.dart' and 'libraryC.dart'\n", |
| 2855 Dart_GetError(result)); | 2986 Dart_GetError(result)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2866 const char* kLibraryChars = | 2997 const char* kLibraryChars = |
| 2867 "#library('lib.dart');" | 2998 "#library('lib.dart');" |
| 2868 "interface X {" | 2999 "interface X {" |
| 2869 " void set handler(void callback(List<int> x));" | 3000 " void set handler(void callback(List<int> x));" |
| 2870 "}"; | 3001 "}"; |
| 2871 Dart_Handle result; | 3002 Dart_Handle result; |
| 2872 | 3003 |
| 2873 // Create a test library and Load up a test script in it. | 3004 // Create a test library and Load up a test script in it. |
| 2874 Dart_Handle url = Dart_NewString(TestCase::url()); | 3005 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 2875 Dart_Handle source = Dart_NewString(kScriptChars); | 3006 Dart_Handle source = Dart_NewString(kScriptChars); |
| 2876 result = Dart_LoadScript(url, source, library_handler); | 3007 Dart_Handle import_map = Dart_NewList(0); |
| 3008 result = Dart_LoadScript(url, source, library_handler, import_map); |
| 2877 | 3009 |
| 2878 url = Dart_NewString("lib.dart"); | 3010 url = Dart_NewString("lib.dart"); |
| 2879 source = Dart_NewString(kLibraryChars); | 3011 source = Dart_NewString(kLibraryChars); |
| 2880 Dart_LoadLibrary(url, source); | 3012 Dart_LoadLibrary(url, source, import_map); |
| 2881 | 3013 |
| 2882 result = Dart_InvokeStatic(result, | 3014 result = Dart_InvokeStatic(result, |
| 2883 Dart_NewString(""), | 3015 Dart_NewString(""), |
| 2884 Dart_NewString("main"), | 3016 Dart_NewString("main"), |
| 2885 0, | 3017 0, |
| 2886 NULL); | 3018 NULL); |
| 2887 EXPECT_VALID(result); | 3019 EXPECT_VALID(result); |
| 2888 } | 3020 } |
| 2889 | 3021 |
| 2890 | 3022 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3001 "}\n"; | 3133 "}\n"; |
| 3002 | 3134 |
| 3003 if (Dart_CurrentIsolate() != NULL) { | 3135 if (Dart_CurrentIsolate() != NULL) { |
| 3004 Dart_ExitIsolate(); | 3136 Dart_ExitIsolate(); |
| 3005 } | 3137 } |
| 3006 Dart_Isolate isolate = TestCase::CreateTestIsolate(); | 3138 Dart_Isolate isolate = TestCase::CreateTestIsolate(); |
| 3007 ASSERT(isolate != NULL); | 3139 ASSERT(isolate != NULL); |
| 3008 Dart_EnterScope(); | 3140 Dart_EnterScope(); |
| 3009 Dart_Handle url = Dart_NewString(TestCase::url()); | 3141 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 3010 Dart_Handle source = Dart_NewString(kScriptChars); | 3142 Dart_Handle source = Dart_NewString(kScriptChars); |
| 3011 Dart_Handle lib = Dart_LoadScript(url, source, TestCase::library_handler); | 3143 Dart_Handle import_map = Dart_NewList(0); |
| 3144 Dart_Handle lib = Dart_LoadScript(url, |
| 3145 source, |
| 3146 TestCase::library_handler, |
| 3147 import_map); |
| 3012 EXPECT_VALID(lib); | 3148 EXPECT_VALID(lib); |
| 3013 Dart_ExitScope(); | 3149 Dart_ExitScope(); |
| 3014 return true; | 3150 return true; |
| 3015 } | 3151 } |
| 3016 | 3152 |
| 3017 | 3153 |
| 3018 // Common code for RunLoop_Success/RunLoop_Failure. | 3154 // Common code for RunLoop_Success/RunLoop_Failure. |
| 3019 static void RunLoopTest(bool throw_exception_child, | 3155 static void RunLoopTest(bool throw_exception_child, |
| 3020 bool throw_exception_parent) { | 3156 bool throw_exception_parent) { |
| 3021 Dart_IsolateCreateCallback saved = Isolate::CreateCallback(); | 3157 Dart_IsolateCreateCallback saved = Isolate::CreateCallback(); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3113 // Tell the other thread that shared_isolate is created. | 3249 // Tell the other thread that shared_isolate is created. |
| 3114 Dart_Handle lib; | 3250 Dart_Handle lib; |
| 3115 { | 3251 { |
| 3116 sync->Enter(); | 3252 sync->Enter(); |
| 3117 char* error = NULL; | 3253 char* error = NULL; |
| 3118 shared_isolate = Dart_CreateIsolate(NULL, NULL, NULL, &error); | 3254 shared_isolate = Dart_CreateIsolate(NULL, NULL, NULL, &error); |
| 3119 EXPECT(shared_isolate != NULL); | 3255 EXPECT(shared_isolate != NULL); |
| 3120 Dart_EnterScope(); | 3256 Dart_EnterScope(); |
| 3121 Dart_Handle url = Dart_NewString(TestCase::url()); | 3257 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 3122 Dart_Handle source = Dart_NewString(kScriptChars); | 3258 Dart_Handle source = Dart_NewString(kScriptChars); |
| 3123 lib = Dart_LoadScript(url, source, TestCase::library_handler); | 3259 Dart_Handle import_map = Dart_NewList(0); |
| 3260 lib = Dart_LoadScript(url, source, TestCase::library_handler, import_map); |
| 3124 EXPECT_VALID(lib); | 3261 EXPECT_VALID(lib); |
| 3125 Dart_Handle result = Dart_SetNativeResolver( | 3262 Dart_Handle result = Dart_SetNativeResolver( |
| 3126 lib, &IsolateInterruptTestNativeLookup); | 3263 lib, &IsolateInterruptTestNativeLookup); |
| 3127 DART_CHECK_VALID(result); | 3264 DART_CHECK_VALID(result); |
| 3128 | 3265 |
| 3129 sync->Notify(); | 3266 sync->Notify(); |
| 3130 sync->Exit(); | 3267 sync->Exit(); |
| 3131 } | 3268 } |
| 3132 | 3269 |
| 3133 Dart_Handle result = Dart_InvokeStatic(lib, | 3270 Dart_Handle result = Dart_InvokeStatic(lib, |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3224 // We should have received the expected number of interrupts. | 3361 // We should have received the expected number of interrupts. |
| 3225 EXPECT_EQ(kInterruptCount, interrupt_count); | 3362 EXPECT_EQ(kInterruptCount, interrupt_count); |
| 3226 | 3363 |
| 3227 // Give the spawned thread enough time to properly exit. | 3364 // Give the spawned thread enough time to properly exit. |
| 3228 Isolate::SetInterruptCallback(saved); | 3365 Isolate::SetInterruptCallback(saved); |
| 3229 } | 3366 } |
| 3230 | 3367 |
| 3231 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 3368 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 3232 | 3369 |
| 3233 } // namespace dart | 3370 } // namespace dart |
| OLD | NEW |