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

Unified Diff: runtime/vm/isolate_reload_test.cc

Issue 2204593011: Reload: Have dangling extracted properties raise NoSuchMethod. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: . Created 4 years, 4 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 | « no previous file | runtime/vm/parser.cc » ('j') | runtime/vm/parser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/isolate_reload_test.cc
diff --git a/runtime/vm/isolate_reload_test.cc b/runtime/vm/isolate_reload_test.cc
index 070897e498c5f13bf166782064c8cb10430ae70e..b6a6c98ac0bb108fa48ecb9fbc435f427653e890 100644
--- a/runtime/vm/isolate_reload_test.cc
+++ b/runtime/vm/isolate_reload_test.cc
@@ -1487,6 +1487,354 @@ TEST_CASE(IsolateReload_TearOff_List_Set) {
}
+TEST_CASE(IsolateReload_DanglingGetter_Instance) {
+ const char* kScript =
+ "import 'test:isolate_reload_helper';\n"
+ "class C {\n"
+ " var x = 3;\n"
+ " var y = 4;\n"
+ "}\n"
+ "invoke(f) {\n"
+ " try {\n"
+ " return f();\n"
+ " } catch (e) {\n"
+ " return e.toString().split('\\n').first;\n"
+ " }\n"
+ "}\n"
+ "main() {\n"
+ " var c = new C();\n"
+ " var f = c#y;\n"
+ " var r1 = invoke(f);\n"
+ " reloadTest();\n"
+ " var r2 = invoke(f);\n"
+ " return '$r1 $r2';\n"
+ "}\n";
+
+ Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
+ EXPECT_VALID(lib);
+
+ const char* kReloadScript =
+ "import 'test:isolate_reload_helper';\n"
+ "class C {\n"
+ " var x = 3;\n"
+ "}\n"
+ "invoke(f) {\n"
+ " try {\n"
+ " return f();\n"
+ " } catch (e) {\n"
+ " return e.toString().split('\\n').first;\n"
+ " }\n"
+ "}\n"
+ "main() {\n"
+ " var c = new C();\n"
+ " var f = c#y;\n"
+ " var r1 = invoke(f);\n"
+ " reloadTest();\n"
+ " var r2 = invoke(f);\n"
+ " return '$r1 $r2';\n"
+ "}\n";
+
+ TestCase::SetReloadTestScript(kReloadScript);
+
+ EXPECT_STREQ("4 Class 'C' has no instance getter 'y'.",
+ SimpleInvokeStr(lib, "main"));
+
+ lib = TestCase::GetReloadErrorOrRootLibrary();
+ EXPECT_VALID(lib);
+}
+
+
+TEST_CASE(IsolateReload_DanglingGetter_Class) {
+ const char* kScript =
+ "import 'test:isolate_reload_helper';\n"
+ "class C {\n"
+ " static var x;\n"
+ " static var y;\n"
+ "}\n"
+ "invoke(f) {\n"
+ " try {\n"
+ " return f();\n"
+ " } catch (e) {\n"
+ " return e.toString().split('\\n').first;\n"
+ " }\n"
+ "}\n"
+ "main() {\n"
+ " C.x = 3;\n"
+ " C.y = 4;\n"
+ " var f = C#y;\n"
+ " var r1 = invoke(f);\n"
+ " reloadTest();\n"
+ " var r2 = invoke(f);\n"
+ " return '$r1 $r2';\n"
+ "}\n";
+
+ Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
+ EXPECT_VALID(lib);
+
+ const char* kReloadScript =
+ "import 'test:isolate_reload_helper';\n"
+ "class C {\n"
+ " static var x;\n"
+ "}\n"
+ "invoke(f) {\n"
+ " try {\n"
+ " return f();\n"
+ " } catch (e) {\n"
+ " return e.toString().split('\\n').first;\n"
+ " }\n"
+ "}\n"
+ "main() {\n"
+ " C.x = 3;\n"
+ " C.y = 4;\n"
+ " var f = C#y;\n"
+ " var r1 = invoke(f);\n"
+ " reloadTest();\n"
+ " var r2 = invoke(f);\n"
+ " return '$r1 $r2';\n"
+ "}\n";
+
+ TestCase::SetReloadTestScript(kReloadScript);
+
+ EXPECT_STREQ("4 No static getter 'y' declared in class 'C'.",
+ SimpleInvokeStr(lib, "main"));
+
+ lib = TestCase::GetReloadErrorOrRootLibrary();
+ EXPECT_VALID(lib);
+}
+
+
+static void IsolateReload_DanlingGetter_LibraryReload(
+ Dart_NativeArguments native_args) {
+ const char* kImportScript2 =
+ "var x;\n";
+ TestCase::AddTestLib("test:other", kImportScript2);
+
+ DART_CHECK_VALID(TestCase::TriggerReload());
+}
+
+
+static Dart_NativeFunction IsolateReload_DanlingGetter_LibraryNativeResolver(
+ Dart_Handle name,
+ int num_of_arguments,
+ bool* auto_setup_scope) {
+ return IsolateReload_DanlingGetter_LibraryReload;
+}
+
+
+TEST_CASE(IsolateReload_DanglingGetter_Library) {
+ const char* kImportScript =
+ "var x;\n"
+ "var y;\n";
+ TestCase::AddTestLib("test:other", kImportScript);
+
+ const char* kScript =
+ "import 'test:other' as prefix;\n"
+ "reloadTest() native 'ReloadTest';\n"
+ "invoke(f) {\n"
+ " try {\n"
+ " return f();\n"
+ " } catch (e) {\n"
+ " return e.toString().split('\\n').first;\n"
+ " }\n"
+ "}\n"
+ "main() {\n"
+ " prefix.x = 3;\n"
+ " prefix.y = 4;\n"
+ " var f = prefix#y;\n"
+ " var r1 = invoke(f);\n"
+ " reloadTest();\n"
+ " var r2 = invoke(f);\n"
+ " return '$r1 $r2';\n"
+ "}\n";
+
+ Dart_Handle lib = TestCase::LoadTestScript(
+ kScript, IsolateReload_DanlingGetter_LibraryNativeResolver);
+ EXPECT_VALID(lib);
+
+ TestCase::SetReloadTestScript(kScript); // Root library does not change.
+
+ EXPECT_STREQ("4 No top-level getter 'y' declared.",
+ SimpleInvokeStr(lib, "main"));
+
+ lib = TestCase::GetReloadErrorOrRootLibrary();
+ EXPECT_VALID(lib);
+}
+
+
+TEST_CASE(IsolateReload_DanglingSetter_Instance) {
+ const char* kScript =
+ "import 'test:isolate_reload_helper';\n"
+ "class C {\n"
+ " var x = 3;\n"
+ " var y = 4;\n"
+ "}\n"
+ "invoke(f, a) {\n"
+ " try {\n"
+ " return f(a);\n"
+ " } catch (e) {\n"
+ " return e.toString().split('\\n').first;\n"
+ " }\n"
+ "}\n"
+ "main() {\n"
+ " var c = new C();\n"
+ " var f = c#y=;\n"
+ " var r1 = invoke(f, 5);\n"
+ " reloadTest();\n"
+ " var r2 = invoke(f, 6);\n"
+ " return '$r1 $r2';\n"
+ "}\n";
+
+ Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
+ EXPECT_VALID(lib);
+
+ const char* kReloadScript =
+ "import 'test:isolate_reload_helper';\n"
+ "class C {\n"
+ " var x = 3;\n"
+ "}\n"
+ "invoke(f, a) {\n"
+ " try {\n"
+ " return f(a);\n"
+ " } catch (e) {\n"
+ " return e.toString().split('\\n').first;\n"
+ " }\n"
+ "}\n"
+ "main() {\n"
+ " var c = new C();\n"
+ " var f = c#y=;\n"
+ " var r1 = invoke(f, 5);\n"
+ " reloadTest();\n"
+ " var r2 = invoke(f, 6);\n"
+ " return '$r1 $r2';\n"
+ "}\n";
+
+ TestCase::SetReloadTestScript(kReloadScript);
+
+ EXPECT_STREQ("null Class 'C' has no instance setter 'y='.",
+ SimpleInvokeStr(lib, "main"));
+
+ lib = TestCase::GetReloadErrorOrRootLibrary();
+ EXPECT_VALID(lib);
+}
+
+
+TEST_CASE(IsolateReload_DanglingSetter_Class) {
+ const char* kScript =
+ "import 'test:isolate_reload_helper';\n"
+ "class C {\n"
+ " static var x;\n"
+ " static var y;\n"
+ "}\n"
+ "invoke(f, a) {\n"
+ " try {\n"
+ " return f(a);\n"
+ " } catch (e) {\n"
+ " return e.toString().split('\\n').first;\n"
+ " }\n"
+ "}\n"
+ "main() {\n"
+ " C.x = 3;\n"
+ " C.y = 4;\n"
+ " var f = C#y=;\n"
+ " var r1 = invoke(f, 5);\n"
+ " reloadTest();\n"
+ " var r2 = invoke(f, 6);\n"
+ " return '$r1 $r2';\n"
+ "}\n";
+
+ Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
+ EXPECT_VALID(lib);
+
+ const char* kReloadScript =
+ "import 'test:isolate_reload_helper';\n"
+ "class C {\n"
+ " static var x;\n"
+ "}\n"
+ "invoke(f, a) {\n"
+ " try {\n"
+ " return f(a);\n"
+ " } catch (e) {\n"
+ " return e.toString().split('\\n').first;\n"
+ " }\n"
+ "}\n"
+ "main() {\n"
+ " C.x = 3;\n"
+ " C.y = 4;\n"
+ " var f = C#y=;\n"
+ " var r1 = invoke(f, 5);\n"
+ " reloadTest();\n"
+ " var r2 = invoke(f, 6);\n"
+ " return '$r1 $r2';\n"
+ "}\n";
+
+ TestCase::SetReloadTestScript(kReloadScript);
+
+ EXPECT_STREQ("5 No static setter 'y=' declared in class 'C'.",
+ SimpleInvokeStr(lib, "main"));
+
+ lib = TestCase::GetReloadErrorOrRootLibrary();
+ EXPECT_VALID(lib);
+}
+
+
+static void IsolateReload_DanlingSetter_LibraryReload(
+ Dart_NativeArguments native_args) {
+ const char* kImportScript2 =
+ "var x;\n";
+ TestCase::AddTestLib("test:other", kImportScript2);
+
+ DART_CHECK_VALID(TestCase::TriggerReload());
+}
+
+
+static Dart_NativeFunction IsolateReload_DanlingSetter_LibraryNativeResolver(
+ Dart_Handle name,
+ int num_of_arguments,
+ bool* auto_setup_scope) {
+ return IsolateReload_DanlingSetter_LibraryReload;
+}
+
+
+TEST_CASE(IsolateReload_DanglingSetter_Library) {
+ const char* kImportScript =
+ "var x;\n"
+ "var y;\n";
+ TestCase::AddTestLib("test:other", kImportScript);
+
+ const char* kScript =
+ "import 'test:other' as prefix;\n"
+ "reloadTest() native 'ReloadTest';\n"
+ "invoke(f, a) {\n"
+ " try {\n"
+ " return f(a);\n"
+ " } catch (e) {\n"
+ " return e.toString().split('\\n').first;\n"
+ " }\n"
+ "}\n"
+ "main() {\n"
+ " prefix.x = 3;\n"
+ " prefix.y = 4;\n"
+ " var f = prefix#y=;\n"
+ " var r1 = invoke(f, 5);\n"
+ " reloadTest();\n"
+ " var r2 = invoke(f, 6);\n"
+ " return '$r1 $r2';\n"
+ "}\n";
+
+ Dart_Handle lib = TestCase::LoadTestScript(
+ kScript, IsolateReload_DanlingSetter_LibraryNativeResolver);
+ EXPECT_VALID(lib);
+
+ TestCase::SetReloadTestScript(kScript); // Root library does not change.
+
+ EXPECT_STREQ("5 No top-level setter 'y=' declared.",
+ SimpleInvokeStr(lib, "main"));
+
+ lib = TestCase::GetReloadErrorOrRootLibrary();
+ EXPECT_VALID(lib);
+}
+
+
TEST_CASE(IsolateReload_EnumEquality) {
const char* kScript =
"enum Fruit {\n"
« no previous file with comments | « no previous file | runtime/vm/parser.cc » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698