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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 11264032: Introduce VM API for the patching mechanism. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Duplicate the code instead to keep error messages. Created 8 years, 2 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
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/dart_api_impl.cc ('k') | no next file » | 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 102864162e0d11a016149355e8404e80177191a5..fe8c40029f507e5a18c0a31da9c670750800ddff 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -5673,6 +5673,42 @@ TEST_CASE(LoadSource_LateLoad) {
}
+TEST_CASE(LoadPatch) {
+ const char* kLibrary1Chars =
+ "#library('library1_name');";
+ const char* kSourceChars =
+ "external int foo();";
+ const char* kPatchChars =
+ "patch int foo() => 42;";
+
+ // Load up a library.
+ Dart_Handle url = Dart_NewString("library1_url");
+ Dart_Handle source = Dart_NewString(kLibrary1Chars);
+ Dart_Handle lib = Dart_LoadLibrary(url, source);
+ EXPECT_VALID(lib);
+ EXPECT(Dart_IsLibrary(lib));
+
+ url = Dart_NewString("source_url");
+ source = Dart_NewString(kSourceChars);
+
+ Dart_Handle result = Dart_LoadSource(lib, url, source);
+ EXPECT_VALID(result);
+
+ url = Dart_NewString("patch_url");
+ source = Dart_NewString(kPatchChars);
+
+ result = Dart_LoadPatch(lib, url, source);
+ EXPECT_VALID(result);
+
+ result = Dart_Invoke(lib, Dart_NewString("foo"), 0, NULL);
+ EXPECT_VALID(result);
+ EXPECT(Dart_IsInteger(result));
+ int64_t value = 0;
+ EXPECT_VALID(Dart_IntegerToInt64(result, &value));
+ EXPECT_EQ(42, value);
+}
+
+
static void PatchNativeFunction(Dart_NativeArguments args) {
Dart_EnterScope();
Dart_SetReturnValue(args, Dart_Null());
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698