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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 15333006: Rewrite double.parse. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Upload Created 7 years, 7 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 | « runtime/lib/double_patch.dart ('k') | sdk/lib/_internal/compiler/implementation/lib/js_helper.dart » ('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 2eb865076fb37f513206afdec837eb782a1aa99a..76bdc4cadbfa261c6625d9937c0dd451f6e5a6c6 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -7737,4 +7737,62 @@ TEST_CASE(ExternalStringDeoptimize) {
EXPECT_EQ(260, value);
}
+
+TEST_CASE(ExternalStringTrimDoubleParse) {
+ const char* kScriptChars =
+ "String str = 'A';\n"
+ "class A {\n"
+ " static change_str(String s) native 'A_change_str';\n"
+ "}\n"
+ "main() {\n"
+ " var externalOneByteString = ' 0.2\\xA0 ';\n;"
+ " A.change_str(externalOneByteString);\n"
+ " var externalTwoByteString = ' \\u{2029}0.6\\u{2029} ';\n"
+ " A.change_str(externalTwoByteString);\n"
+ " var x = double.parse(externalOneByteString);\n"
+ " var y = double.parse(externalTwoByteString);\n"
+ " return ((x + y) * 10).toInt();\n"
+ "}\n";
+ Dart_Handle lib =
+ TestCase::LoadTestScript(kScriptChars,
+ &ExternalStringDeoptimize_native_lookup);
+ Dart_Handle result = Dart_Invoke(lib,
+ NewString("main"),
+ 0,
+ NULL);
+ int64_t value = 0;
+ result = Dart_IntegerToInt64(result, &value);
+ EXPECT_VALID(result);
+ EXPECT_EQ(8, value);
+}
+
+
+TEST_CASE(ExternalStringDoubleParse) {
+ const char* kScriptChars =
+ "String str = 'A';\n"
+ "class A {\n"
+ " static change_str(String s) native 'A_change_str';\n"
+ "}\n"
+ "main() {\n"
+ " var externalOneByteString = '0.2';\n;"
+ " A.change_str(externalOneByteString);\n"
+ " var externalTwoByteString = '0.6';\n"
+ " A.change_str(externalTwoByteString);\n"
+ " var x = double.parse(externalOneByteString);\n"
+ " var y = double.parse(externalTwoByteString);\n"
+ " return ((x + y) * 10).toInt();\n"
+ "}\n";
+ Dart_Handle lib =
+ TestCase::LoadTestScript(kScriptChars,
+ &ExternalStringDeoptimize_native_lookup);
+ Dart_Handle result = Dart_Invoke(lib,
+ NewString("main"),
+ 0,
+ NULL);
+ int64_t value = 0;
+ result = Dart_IntegerToInt64(result, &value);
+ EXPECT_VALID(result);
+ EXPECT_EQ(8, value);
+}
+
} // namespace dart
« no previous file with comments | « runtime/lib/double_patch.dart ('k') | sdk/lib/_internal/compiler/implementation/lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698