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

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

Issue 12282038: Remove deprecated string features. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 7377 matching lines...) Expand 10 before | Expand all | Expand 10 after
7388 TEST_CASE(ExternalStringDeoptimize) { 7388 TEST_CASE(ExternalStringDeoptimize) {
7389 const char* kScriptChars = 7389 const char* kScriptChars =
7390 "String str = 'A';\n" 7390 "String str = 'A';\n"
7391 "class A {\n" 7391 "class A {\n"
7392 " static change_str(String s) native 'A_change_str';\n" 7392 " static change_str(String s) native 'A_change_str';\n"
7393 "}\n" 7393 "}\n"
7394 "sum_chars(String s, bool b) {\n" 7394 "sum_chars(String s, bool b) {\n"
7395 " var result = 0;\n" 7395 " var result = 0;\n"
7396 " for (var i = 0; i < s.length; i++) {\n" 7396 " for (var i = 0; i < s.length; i++) {\n"
7397 " if (b && i == 0) A.change_str(str);\n" 7397 " if (b && i == 0) A.change_str(str);\n"
7398 " result += s.charCodeAt(i);" 7398 " result += s.codeUnitAt(i);"
7399 " }\n" 7399 " }\n"
7400 " return result;\n" 7400 " return result;\n"
7401 "}\n" 7401 "}\n"
7402 "main() {\n" 7402 "main() {\n"
7403 " str = '$str$str';\n" 7403 " str = '$str$str';\n"
7404 " for (var i = 0; i < 2000; i++) sum_chars(str, false);\n" 7404 " for (var i = 0; i < 2000; i++) sum_chars(str, false);\n"
7405 " var x = sum_chars(str, false);\n" 7405 " var x = sum_chars(str, false);\n"
7406 " var y = sum_chars(str, true);\n" 7406 " var y = sum_chars(str, true);\n"
7407 " return x + y;\n" 7407 " return x + y;\n"
7408 "}\n"; 7408 "}\n";
7409 Dart_Handle lib = 7409 Dart_Handle lib =
7410 TestCase::LoadTestScript(kScriptChars, 7410 TestCase::LoadTestScript(kScriptChars,
7411 &ExternalStringDeoptimize_native_lookup); 7411 &ExternalStringDeoptimize_native_lookup);
7412 Dart_Handle result = Dart_Invoke(lib, 7412 Dart_Handle result = Dart_Invoke(lib,
7413 NewString("main"), 7413 NewString("main"),
7414 0, 7414 0,
7415 NULL); 7415 NULL);
7416 int64_t value = 0; 7416 int64_t value = 0;
7417 result = Dart_IntegerToInt64(result, &value); 7417 result = Dart_IntegerToInt64(result, &value);
7418 EXPECT_VALID(result); 7418 EXPECT_VALID(result);
7419 EXPECT_EQ(260, value); 7419 EXPECT_EQ(260, value);
7420 } 7420 }
7421 7421
7422 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 7422 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
7423 7423
7424 } // namespace dart 7424 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698