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

Side by Side Diff: runtime/vm/dart_api_impl_test.cc

Issue 15868003: Revert "Rewrite double.parse." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 "bin/builtin.h" 6 #include "bin/builtin.h"
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "platform/json.h" 8 #include "platform/json.h"
9 #include "platform/utils.h" 9 #include "platform/utils.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 7719 matching lines...) Expand 10 before | Expand all | Expand 10 after
7730 Dart_Handle result = Dart_Invoke(lib, 7730 Dart_Handle result = Dart_Invoke(lib,
7731 NewString("main"), 7731 NewString("main"),
7732 0, 7732 0,
7733 NULL); 7733 NULL);
7734 int64_t value = 0; 7734 int64_t value = 0;
7735 result = Dart_IntegerToInt64(result, &value); 7735 result = Dart_IntegerToInt64(result, &value);
7736 EXPECT_VALID(result); 7736 EXPECT_VALID(result);
7737 EXPECT_EQ(260, value); 7737 EXPECT_EQ(260, value);
7738 } 7738 }
7739 7739
7740
7741 TEST_CASE(ExternalStringTrimDoubleParse) {
7742 const char* kScriptChars =
7743 "String str = 'A';\n"
7744 "class A {\n"
7745 " static change_str(String s) native 'A_change_str';\n"
7746 "}\n"
7747 "main() {\n"
7748 " var externalOneByteString = ' 0.2\\xA0 ';\n;"
7749 " A.change_str(externalOneByteString);\n"
7750 " var externalTwoByteString = ' \\u{2029}0.6\\u{2029} ';\n"
7751 " A.change_str(externalTwoByteString);\n"
7752 " var x = double.parse(externalOneByteString);\n"
7753 " var y = double.parse(externalTwoByteString);\n"
7754 " return ((x + y) * 10).toInt();\n"
7755 "}\n";
7756 Dart_Handle lib =
7757 TestCase::LoadTestScript(kScriptChars,
7758 &ExternalStringDeoptimize_native_lookup);
7759 Dart_Handle result = Dart_Invoke(lib,
7760 NewString("main"),
7761 0,
7762 NULL);
7763 int64_t value = 0;
7764 result = Dart_IntegerToInt64(result, &value);
7765 EXPECT_VALID(result);
7766 EXPECT_EQ(8, value);
7767 }
7768
7769
7770 TEST_CASE(ExternalStringDoubleParse) {
7771 const char* kScriptChars =
7772 "String str = 'A';\n"
7773 "class A {\n"
7774 " static change_str(String s) native 'A_change_str';\n"
7775 "}\n"
7776 "main() {\n"
7777 " var externalOneByteString = '0.2';\n;"
7778 " A.change_str(externalOneByteString);\n"
7779 " var externalTwoByteString = '0.6';\n"
7780 " A.change_str(externalTwoByteString);\n"
7781 " var x = double.parse(externalOneByteString);\n"
7782 " var y = double.parse(externalTwoByteString);\n"
7783 " return ((x + y) * 10).toInt();\n"
7784 "}\n";
7785 Dart_Handle lib =
7786 TestCase::LoadTestScript(kScriptChars,
7787 &ExternalStringDeoptimize_native_lookup);
7788 Dart_Handle result = Dart_Invoke(lib,
7789 NewString("main"),
7790 0,
7791 NULL);
7792 int64_t value = 0;
7793 result = Dart_IntegerToInt64(result, &value);
7794 EXPECT_VALID(result);
7795 EXPECT_EQ(8, value);
7796 }
7797
7798 } // namespace dart 7740 } // namespace dart
OLDNEW
« 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