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 |