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

Side by Side 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: Address comments. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "platform/json.h" 7 #include "platform/json.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 7715 matching lines...) Expand 10 before | Expand all | Expand 10 after
7726 Dart_Handle result = Dart_Invoke(lib, 7726 Dart_Handle result = Dart_Invoke(lib,
7727 NewString("main"), 7727 NewString("main"),
7728 0, 7728 0,
7729 NULL); 7729 NULL);
7730 int64_t value = 0; 7730 int64_t value = 0;
7731 result = Dart_IntegerToInt64(result, &value); 7731 result = Dart_IntegerToInt64(result, &value);
7732 EXPECT_VALID(result); 7732 EXPECT_VALID(result);
7733 EXPECT_EQ(260, value); 7733 EXPECT_EQ(260, value);
7734 } 7734 }
7735 7735
7736
7737 TEST_CASE(ExternalStringTrimDoubleParse) {
7738 const char* kScriptChars =
7739 "String str = 'A';\n"
7740 "class A {\n"
7741 " static change_str(String s) native 'A_change_str';\n"
7742 "}\n"
7743 "main() {\n"
7744 " var externalOneByteString = ' 0.2\\xA0 ';\n;"
7745 " A.change_str(externalOneByteString);\n"
7746 " var externalTwoByteString = ' \\u{2029}0.6\\u{2029} ';\n"
7747 " A.change_str(externalTwoByteString);\n"
7748 " var x = double.parse(externalOneByteString);\n"
7749 " var y = double.parse(externalTwoByteString);\n"
7750 " return ((x + y) * 10).toInt();\n"
7751 "}\n";
7752 Dart_Handle lib =
7753 TestCase::LoadTestScript(kScriptChars,
7754 &ExternalStringDeoptimize_native_lookup);
7755 Dart_Handle result = Dart_Invoke(lib,
7756 NewString("main"),
7757 0,
7758 NULL);
7759 int64_t value = 0;
7760 result = Dart_IntegerToInt64(result, &value);
7761 EXPECT_VALID(result);
7762 EXPECT_EQ(8, value);
7763 }
7764
7765
7766 TEST_CASE(ExternalStringDoubleParse) {
7767 const char* kScriptChars =
7768 "String str = 'A';\n"
7769 "class A {\n"
7770 " static change_str(String s) native 'A_change_str';\n"
7771 "}\n"
7772 "main() {\n"
7773 " var externalOneByteString = '0.2';\n;"
7774 " A.change_str(externalOneByteString);\n"
7775 " var externalTwoByteString = '0.6';\n"
7776 " A.change_str(externalTwoByteString);\n"
7777 " var x = double.parse(externalOneByteString);\n"
7778 " var y = double.parse(externalTwoByteString);\n"
7779 " return ((x + y) * 10).toInt();\n"
7780 "}\n";
7781 Dart_Handle lib =
7782 TestCase::LoadTestScript(kScriptChars,
7783 &ExternalStringDeoptimize_native_lookup);
7784 Dart_Handle result = Dart_Invoke(lib,
7785 NewString("main"),
7786 0,
7787 NULL);
7788 int64_t value = 0;
7789 result = Dart_IntegerToInt64(result, &value);
7790 EXPECT_VALID(result);
7791 EXPECT_EQ(8, value);
7792 }
7793
7736 } // namespace dart 7794 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698