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

Side by Side Diff: vm/dart_api_impl_test.cc

Issue 10433003: Make Dart_GetClass work for private classes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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 | « vm/dart_api_impl.cc ('k') | vm/object.h » ('j') | 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/utils.h" 7 #include "platform/utils.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_api_state.h" 10 #include "vm/dart_api_state.h"
(...skipping 3452 matching lines...) Expand 10 before | Expand all | Expand 10 after
3463 3463
3464 int64_t value = 0; 3464 int64_t value = 0;
3465 result = Dart_IntegerToInt64(result, &value); 3465 result = Dart_IntegerToInt64(result, &value);
3466 EXPECT_VALID(result); 3466 EXPECT_VALID(result);
3467 EXPECT_EQ(3, value); 3467 EXPECT_EQ(3, value);
3468 } 3468 }
3469 3469
3470 3470
3471 TEST_CASE(GetClass) { 3471 TEST_CASE(GetClass) {
3472 const char* kScriptChars = 3472 const char* kScriptChars =
3473 "class DoesExist {" 3473 "class Class {\n"
3474 "}"; 3474 " static var name = 'Class';\n"
3475 "}\n"
3476 "\n"
3477 "class _Class {\n"
3478 " static var name = '_Class';\n"
3479 "}\n";
3475 3480
3476 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 3481 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
3477 3482
3478 // Lookup a class that does exist. 3483 // Lookup a class.
3479 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("DoesExist")); 3484 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("Class"));
3480 EXPECT_VALID(cls); 3485 EXPECT_VALID(cls);
3486 Dart_Handle name = Dart_GetField(cls, Dart_NewString("name"));
3487 EXPECT_VALID(name);
3488 const char* name_cstr = "";
3489 EXPECT_VALID(Dart_StringToCString(name, &name_cstr));
3490 EXPECT_STREQ("Class", name_cstr);
3491
3492 // Lookup a private class.
3493 cls = Dart_GetClass(lib, Dart_NewString("_Class"));
3494 EXPECT_VALID(cls);
3495 name = Dart_GetField(cls, Dart_NewString("name"));
3496 EXPECT_VALID(name);
3497 name_cstr = "";
3498 EXPECT_VALID(Dart_StringToCString(name, &name_cstr));
3499 EXPECT_STREQ("_Class", name_cstr);
3481 3500
3482 // Lookup a class that does not exist. 3501 // Lookup a class that does not exist.
3483 cls = Dart_GetClass(lib, Dart_NewString("DoesNotExist")); 3502 cls = Dart_GetClass(lib, Dart_NewString("DoesNotExist"));
3484 EXPECT(Dart_IsError(cls)); 3503 EXPECT(Dart_IsError(cls));
3485 EXPECT_STREQ("Class 'DoesNotExist' not found in library 'dart:test-lib'.", 3504 EXPECT_STREQ("Class 'DoesNotExist' not found in library 'dart:test-lib'.",
3486 Dart_GetError(cls)); 3505 Dart_GetError(cls));
3506
3507 // Lookup a class from an error library. The error propagates.
3508 cls = Dart_GetClass(Api::NewError("myerror"), Dart_NewString("Class"));
3509 EXPECT(Dart_IsError(cls));
3510 EXPECT_STREQ("myerror", Dart_GetError(cls));
3511
3512 // Lookup a class using an error class name. The error propagates.
3513 cls = Dart_GetClass(lib, Api::NewError("myerror"));
3514 EXPECT(Dart_IsError(cls));
3515 EXPECT_STREQ("myerror", Dart_GetError(cls));
3487 } 3516 }
3488 3517
3489 3518
3490 TEST_CASE(InstanceOf) { 3519 TEST_CASE(InstanceOf) {
3491 const char* kScriptChars = 3520 const char* kScriptChars =
3492 "class OtherClass {\n" 3521 "class OtherClass {\n"
3493 " static returnNull() { return null; }\n" 3522 " static returnNull() { return null; }\n"
3494 "}\n" 3523 "}\n"
3495 "class InstanceOfTest {\n" 3524 "class InstanceOfTest {\n"
3496 " InstanceOfTest() {}\n" 3525 " InstanceOfTest() {}\n"
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
4678 // We should have received the expected number of interrupts. 4707 // We should have received the expected number of interrupts.
4679 EXPECT_EQ(kInterruptCount, interrupt_count); 4708 EXPECT_EQ(kInterruptCount, interrupt_count);
4680 4709
4681 // Give the spawned thread enough time to properly exit. 4710 // Give the spawned thread enough time to properly exit.
4682 Isolate::SetInterruptCallback(saved); 4711 Isolate::SetInterruptCallback(saved);
4683 } 4712 }
4684 4713
4685 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 4714 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
4686 4715
4687 } // namespace dart 4716 } // namespace dart
OLDNEW
« no previous file with comments | « vm/dart_api_impl.cc ('k') | vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698