Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(798)

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 1569833003: Adds strict compilation flags to Dart_IsolateFlags (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698