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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 23982002: Fix bug where Script files that only contained patches were lost from the list of LoadedScripts() T… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: removed dupe code Created 7 years, 3 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/object.cc » ('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 a9def3fb87a03e00da46727cda36ef658435893d..be5c3772e4057472777e32661c9ead1b67da0e15 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -5296,8 +5296,13 @@ TEST_CASE(ParsePatchLibrary) {
" external B.named(x);\n"
" external B(v);\n"
"}\n"
+ "class C {\n"
+ " external int method();\n"
+ "}\n"
+ "\n"
"external int unpatched();\n"
"external int topLevel(var value);\n"
+ "external int topLevel2(var value);\n"
"external int get topLevelGetter;\n"
"external void set topLevelSetter(int value);\n";
@@ -5322,7 +5327,19 @@ TEST_CASE(ParsePatchLibrary) {
"patch int set topLevelSetter(value) { _topLevelValue = value; }\n"
"patch int get topLevelGetter => 2 * _topLevelValue;\n"
// Allow top level methods named patch.
- "patch(x) => x*3;\n";
+ "patch(x) => x*3;\n"
+ ; // NOLINT
+
+ const char* kPatchClassOnlyChars =
+ "patch class C {\n"
+ " /*patch*/ int method() {\n"
+ " return 42;\n"
+ " }\n"
+ "}\n"
+ ; // NOLINT
+
+ const char* kPatchNoClassChars =
+ "patch topLevel2(x) => x * 2;\n";
const char* kScriptChars =
"import 'theLibrary';\n"
@@ -5356,17 +5373,27 @@ TEST_CASE(ParsePatchLibrary) {
result = Dart_LoadLibrary(url, source);
EXPECT_VALID(result);
- const String& patch_url = String::Handle(String::New("theLibrary patch"));
- const String& patch_source = String::Handle(String::New(kPatchChars));
- const Script& patch_script = Script::Handle(Script::New(
- patch_url, patch_source, RawScript::kPatchTag));
-
+ const char* patchNames[] = { "main library patch",
+ "patch class only",
+ "patch no class" };
+ const char* patches[] = { kPatchChars,
+ kPatchClassOnlyChars,
+ kPatchNoClassChars };
const String& lib_url = String::Handle(String::New("theLibrary"));
+
const Library& lib = Library::Handle(Library::LookupLibrary(lib_url));
- const Error& err = Error::Handle(lib.Patch(patch_script));
- if (!err.IsNull()) {
- OS::Print("Patching error: %s\n", err.ToErrorCString());
- EXPECT(false);
+
+ for (int i = 0; i < 3; i++) {
+ const String& patch_url = String::Handle(String::New(patchNames[i]));
+ const String& patch_source = String::Handle(String::New(patches[i]));
+ const Script& patch_script = Script::Handle(Script::New(
+ patch_url, patch_source, RawScript::kPatchTag));
+
+ const Error& err = Error::Handle(lib.Patch(patch_script));
+ if (!err.IsNull()) {
+ OS::Print("Patching error: %s\n", err.ToErrorCString());
+ EXPECT(false);
+ }
}
result = Dart_SetNativeResolver(result, &PatchNativeResolver);
EXPECT_VALID(result);
@@ -5421,6 +5448,10 @@ TEST_CASE(ParsePatchLibrary) {
EXPECT(Dart_IsInteger(result));
EXPECT_VALID(Dart_IntegerToInt64(result, &value));
EXPECT_EQ(8, value);
+
+ // Make sure all source files show up in the patched library.
+ const Array& lib_scripts = Array::Handle(lib.LoadedScripts());
+ EXPECT_EQ(4, lib_scripts.Length());
}
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698