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

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

Issue 15353002: Add a call to CheckIsolateState in all paths of Dart_GetField and Dart_SetField. (Closed) Base URL: http://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
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3498 matching lines...) Expand 10 before | Expand all | Expand 10 after
3509 EXPECT_VALID(result); 3509 EXPECT_VALID(result);
3510 3510
3511 // We now get the new value for fld2, not the initializer 3511 // We now get the new value for fld2, not the initializer
3512 result = Dart_GetField(cls, NewString("fld2")); 3512 result = Dart_GetField(cls, NewString("fld2"));
3513 EXPECT_VALID(result); 3513 EXPECT_VALID(result);
3514 result = Dart_IntegerToInt64(result, &value); 3514 result = Dart_IntegerToInt64(result, &value);
3515 EXPECT_EQ(13, value); 3515 EXPECT_EQ(13, value);
3516 } 3516 }
3517 3517
3518 3518
3519 TEST_CASE(GetField_CheckIsolate) {
3520 const char* kScriptChars =
3521 "class TestClass {\n"
3522 " static int fld2 = 11;\n"
3523 " static void testMain() {\n"
3524 " }\n"
3525 "}\n";
3526 Dart_Handle result;
3527 int64_t value = 0;
3528
3529 // Create a test library and Load up a test script in it.
3530 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
3531 Dart_Handle cls = Dart_GetClass(lib, NewString("TestClass"));
3532 EXPECT_VALID(cls);
3533
3534 result = Dart_GetField(cls, NewString("fld2"));
3535 EXPECT_VALID(result);
3536 result = Dart_IntegerToInt64(result, &value);
3537 EXPECT_EQ(11, value);
3538 }
3539
3540
3541 TEST_CASE(SetField_CheckIsolate) {
3542 const char* kScriptChars =
3543 "class TestClass {\n"
3544 " static int fld2 = 11;\n"
3545 " static void testMain() {\n"
3546 " }\n"
3547 "}\n";
3548 Dart_Handle result;
3549 int64_t value = 0;
3550
3551 // Create a test library and Load up a test script in it.
3552 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
3553 Dart_Handle cls = Dart_GetClass(lib, NewString("TestClass"));
3554 EXPECT_VALID(cls);
3555
3556 result = Dart_SetField(cls, NewString("fld2"), Dart_NewInteger(13));
3557 EXPECT_VALID(result);
3558
3559 result = Dart_GetField(cls, NewString("fld2"));
3560 EXPECT_VALID(result);
3561 result = Dart_IntegerToInt64(result, &value);
3562 EXPECT_EQ(13, value);
3563 }
3564
3565
3519 TEST_CASE(New) { 3566 TEST_CASE(New) {
3520 const char* kScriptChars = 3567 const char* kScriptChars =
3521 "class MyClass {\n" 3568 "class MyClass {\n"
3522 " MyClass() : foo = 7 {}\n" 3569 " MyClass() : foo = 7 {}\n"
3523 " MyClass.named(value) : foo = value {}\n" 3570 " MyClass.named(value) : foo = value {}\n"
3524 " MyClass._hidden(value) : foo = -value {}\n" 3571 " MyClass._hidden(value) : foo = -value {}\n"
3525 " MyClass.exception(value) : foo = value {\n" 3572 " MyClass.exception(value) : foo = value {\n"
3526 " throw 'ConstructorDeath';\n" 3573 " throw 'ConstructorDeath';\n"
3527 " }\n" 3574 " }\n"
3528 " factory MyClass.multiply(value) {\n" 3575 " factory MyClass.multiply(value) {\n"
(...skipping 4151 matching lines...) Expand 10 before | Expand all | Expand 10 after
7680 NewString("main"), 7727 NewString("main"),
7681 0, 7728 0,
7682 NULL); 7729 NULL);
7683 int64_t value = 0; 7730 int64_t value = 0;
7684 result = Dart_IntegerToInt64(result, &value); 7731 result = Dart_IntegerToInt64(result, &value);
7685 EXPECT_VALID(result); 7732 EXPECT_VALID(result);
7686 EXPECT_EQ(260, value); 7733 EXPECT_EQ(260, value);
7687 } 7734 }
7688 7735
7689 } // namespace dart 7736 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698