| Index: runtime/vm/dart_api_impl_test.cc
|
| diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
|
| index 591373ab4e2f4fd9d7ecfa41df706bc4b520f315..953a859ecd4d50963a57ad8ae174fdf8c5c9c2b2 100644
|
| --- a/runtime/vm/dart_api_impl_test.cc
|
| +++ b/runtime/vm/dart_api_impl_test.cc
|
| @@ -3341,7 +3341,7 @@ UNIT_TEST_CASE(CurrentIsolateData) {
|
| }
|
|
|
|
|
| -TEST_CASE(IsolateSetCheckedMode) {
|
| +UNIT_TEST_CASE(IsolateSetCheckedMode) {
|
| const char* kScriptChars =
|
| "int bad1() {\n"
|
| " int foo = 'string';\n"
|
| @@ -3352,23 +3352,49 @@ TEST_CASE(IsolateSetCheckedMode) {
|
| " int five = 5;\n"
|
| " return five;"
|
| "}\n";
|
| - Dart_Handle result;
|
|
|
| - // Create a test library and Load up a test script in it.
|
| - Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
|
| - result = Dart_IsolateSetStrictCompilation(true);
|
| - EXPECT_VALID(result);
|
| + // Create an isolate with checked mode flags.
|
| + Dart_IsolateFlags api_flags;
|
| + api_flags.version = DART_FLAGS_CURRENT_VERSION;
|
| + api_flags.enable_type_checks = true;
|
| + api_flags.enable_asserts = true;
|
| + api_flags.enable_error_on_bad_type = true;
|
| + api_flags.enable_error_on_bad_override = true;
|
|
|
| - result = Dart_Invoke(lib, NewString("bad1"), 0, NULL);
|
| - EXPECT_ERROR(result, "Unhandled exception:\n"
|
| - "type 'String' is not a subtype of type 'int' of 'foo'");
|
| + char* err;
|
| + Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL,
|
| + bin::isolate_snapshot_buffer,
|
| + &api_flags,
|
| + NULL, &err);
|
| + if (isolate == NULL) {
|
| + OS::Print("Creation of isolate failed '%s'\n", err);
|
| + free(err);
|
| + }
|
| + EXPECT(isolate != NULL);
|
|
|
| - result = Dart_Invoke(lib, NewString("good1"), 0, NULL);
|
| - EXPECT_VALID(result);
|
| + {
|
| + Dart_EnterScope();
|
| + Dart_Handle url = NewString(TestCase::url());
|
| + Dart_Handle source = NewString(kScriptChars);
|
| + Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler);
|
| + EXPECT_VALID(result);
|
| + Dart_Handle lib = Dart_LoadScript(url, source, 0, 0);
|
| + EXPECT_VALID(lib);
|
| + result = Dart_FinalizeLoading(false);
|
| + EXPECT_VALID(result);
|
| + result = Dart_Invoke(lib, NewString("bad1"), 0, NULL);
|
| + EXPECT_ERROR(result, "Unhandled exception:\n"
|
| + "type 'String' is not a subtype of type 'int' of 'foo'");
|
|
|
| - result = Dart_IsolateSetStrictCompilation(false);
|
| - EXPECT_ERROR(result, "Dart_IsolateSetStrictCompilation expects that the "
|
| - "isolate has not yet compiled code.");
|
| + result = Dart_Invoke(lib, NewString("good1"), 0, NULL);
|
| + EXPECT_VALID(result);
|
| + Dart_ExitScope();
|
| + }
|
| +
|
| + EXPECT(isolate != NULL);
|
| +
|
| + // Shutdown the isolate.
|
| + Dart_ShutdownIsolate();
|
| }
|
|
|
|
|
|
|