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

Unified Diff: vm/dart_api_impl_test.cc

Issue 11580003: Changes per discussion with Anton (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years 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
« include/dart_api.h ('K') | « 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: vm/dart_api_impl_test.cc
===================================================================
--- vm/dart_api_impl_test.cc (revision 16135)
+++ vm/dart_api_impl_test.cc (working copy)
@@ -532,6 +532,15 @@
EXPECT(Dart_IsStringLatin1(str8));
EXPECT(!Dart_IsExternalString(str8));
+ uint8_t* latin1_array = NULL;
+ Dart_Handle result = Dart_StringToLatin1(str8, &latin1_array, &len);
+ EXPECT_VALID(result);
+ EXPECT_EQ(4, len);
+ EXPECT(latin1_array != NULL);
+ for (intptr_t i = 0; i < len; i++) {
+ EXPECT_EQ(data8[i], latin1_array[i]);
+ }
+
Dart_Handle ext8 = Dart_NewExternalLatin1String(data8, ARRAY_SIZE(data8),
NULL, NULL);
EXPECT_VALID(ext8);
@@ -7315,6 +7324,34 @@
}
+TEST_CASE(ExternalizeConstantStrings) {
+ const char* kScriptChars =
+ "void testMain() {\n"
+ " return 'constant string';\n"
+ "}\n";
+
+ Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
+ Dart_Handle result = Dart_Invoke(lib,
+ NewString("testMain"),
+ 0,
+ NULL);
+ const char* expected_str = "constant string";
+ const intptr_t kExpectedLen = 15;
+ int peer = 40;
+ uint8_t ext_str[kExpectedLen];
+ Dart_Handle str = Dart_MakeExternalString(result,
+ ext_str,
+ kExpectedLen,
+ &peer,
+ MakeExternalCback);
+
+ EXPECT(Dart_IsNull(str));
+ for (intptr_t i = 0; i < kExpectedLen; i++) {
+ EXPECT_EQ(expected_str[i], ext_str[i]);
+ }
+}
+
+
TEST_CASE(LazyLoadDeoptimizes) {
const char* kLoadFirst =
"start(a) {\n"
« include/dart_api.h ('K') | « vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698