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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 8507035: Here's a template for how I plan on doing error-checking on inputs for (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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') | 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
===================================================================
--- runtime/vm/dart_api_impl_test.cc (revision 1409)
+++ runtime/vm/dart_api_impl_test.cc (working copy)
@@ -13,7 +13,6 @@
namespace dart {
-#if defined(TARGET_ARCH_IA32)
UNIT_TEST_CASE(Dart_Error) {
Dart_CreateIsolate(NULL, NULL);
Dart_EnterScope();
@@ -25,7 +24,6 @@
Dart_ExitScope();
Dart_ShutdownIsolate();
}
-#endif
UNIT_TEST_CASE(Null) {
@@ -1791,6 +1789,57 @@
}
+UNIT_TEST_CASE(LookupLibrary) {
+ const char* kScriptChars =
+ "#import('library1.dart');"
+ "main() {}";
+ const char* kLibrary1Chars =
+ "#library('library1.dart');"
+ "#import('library2.dart');";
+
+ Dart_CreateIsolate(NULL, NULL);
+ Dart_EnterScope();
+
+ // Create a test library and Load up a test script in it.
+ Dart_Handle url = Dart_NewString(TestCase::url());
+ Dart_Handle source = Dart_NewString(kScriptChars);
+ Dart_Handle result = Dart_LoadScript(url, source, library_handler);
+ EXPECT_VALID(result);
+
+ url = Dart_NewString("library1.dart");
+ source = Dart_NewString(kLibrary1Chars);
+ result = Dart_LoadLibrary(url, source);
+ EXPECT_VALID(result);
+
+ result = Dart_LookupLibrary(url);
+ EXPECT_VALID(result);
+
+ result = Dart_LookupLibrary(Dart_Null());
+ EXPECT(!Dart_IsValid(result));
+ EXPECT_STREQ("Dart_LookupLibrary expects argument 'url' to be non-null.",
+ Dart_GetError(result));
+
+ result = Dart_LookupLibrary(Dart_True());
+ EXPECT(!Dart_IsValid(result));
+ EXPECT_STREQ(
+ "Dart_LookupLibrary expects argument 'url' to be of type String.",
+ Dart_GetError(result));
+
+ result = Dart_LookupLibrary(Dart_Error("incoming error pass-thru"));
+ EXPECT(!Dart_IsValid(result));
+ EXPECT_STREQ("incoming error pass-thru", Dart_GetError(result));
+
+ url = Dart_NewString("noodles.dart");
+ result = Dart_LookupLibrary(url);
+ EXPECT(!Dart_IsValid(result));
+ EXPECT_STREQ("Dart_LookupLibrary: library 'noodles.dart' not found.",
+ Dart_GetError(result));
+
+ Dart_ExitScope();
+ Dart_ShutdownIsolate();
+}
+
+
UNIT_TEST_CASE(ImportLibrary1) {
const char* kScriptChars =
"#import('library1.dart');"
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698