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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 8492015: Allow printf-style arguments for Dart_Error and Api::Error. (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
« 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
===================================================================
--- runtime/vm/dart_api_impl_test.cc (revision 1265)
+++ runtime/vm/dart_api_impl_test.cc (working copy)
@@ -13,6 +13,19 @@
namespace dart {
+UNIT_TEST_CASE(Dart_Error) {
+ Dart_CreateIsolate(NULL, NULL);
+ Dart_EnterScope();
+
+ Dart_Handle error = Dart_Error("An %s", "error");
+ EXPECT(!Dart_IsValid(error));
+ EXPECT_STREQ("An error", Dart_GetError(error));
+
+ Dart_ExitScope();
+ Dart_ShutdownIsolate();
+}
+
+
UNIT_TEST_CASE(Null) {
Dart_CreateIsolate(NULL, NULL);
Dart_EnterScope(); // Enter a Dart API scope for the unit test.
@@ -1551,6 +1564,30 @@
}
+UNIT_TEST_CASE(GetClass) {
+ const char* kScriptChars =
+ "class DoesExist {"
+ "}";
+
+ Dart_CreateIsolate(NULL, NULL);
+ Dart_EnterScope();
+ Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
+
+ // Lookup a class that does exist.
+ Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("DoesExist"));
+ EXPECT_VALID(cls);
+
+ // Lookup a class that does not exist.
+ cls = Dart_GetClass(lib, Dart_NewString("DoesNotExist"));
+ EXPECT(!Dart_IsValid(cls));
+ EXPECT_STREQ("Class 'DoesNotExist' not found in library 'dart:test-lib'.",
+ Dart_GetError(cls));
+
+ Dart_ExitScope();
+ Dart_ShutdownIsolate();
+}
+
+
UNIT_TEST_CASE(InstanceOf) {
const char* kScriptChars =
"class OtherClass {\n"
« 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