OLD | NEW |
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 "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/assembler.h" | 6 #include "vm/assembler.h" |
7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
(...skipping 2652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2663 EXPECT(Field::IsGetterName(getter_f)); | 2663 EXPECT(Field::IsGetterName(getter_f)); |
2664 EXPECT(!Field::IsSetterName(getter_f)); | 2664 EXPECT(!Field::IsSetterName(getter_f)); |
2665 EXPECT(!Field::IsGetterName(setter_f)); | 2665 EXPECT(!Field::IsGetterName(setter_f)); |
2666 EXPECT(Field::IsSetterName(setter_f)); | 2666 EXPECT(Field::IsSetterName(setter_f)); |
2667 EXPECT_STREQ(f.ToCString(), | 2667 EXPECT_STREQ(f.ToCString(), |
2668 String::Handle(Field::NameFromGetter(getter_f)).ToCString()); | 2668 String::Handle(Field::NameFromGetter(getter_f)).ToCString()); |
2669 EXPECT_STREQ(f.ToCString(), | 2669 EXPECT_STREQ(f.ToCString(), |
2670 String::Handle(Field::NameFromSetter(setter_f)).ToCString()); | 2670 String::Handle(Field::NameFromSetter(setter_f)).ToCString()); |
2671 } | 2671 } |
2672 | 2672 |
| 2673 |
| 2674 // Expose helper function from object.cc for testing. |
| 2675 bool MatchesIgnorePrivate(const String& name, const String& private_name); |
| 2676 |
| 2677 |
| 2678 TEST_CASE(MatchesIgnorePrivate) { |
| 2679 String& munged_name = String::Handle(); |
| 2680 String& bare_name = String::Handle(); |
| 2681 |
| 2682 // No private suffix => no match. |
| 2683 munged_name = String::New("foo"); |
| 2684 bare_name = String::New("foo"); |
| 2685 EXPECT(!MatchesIgnorePrivate(munged_name, bare_name)); |
| 2686 |
| 2687 munged_name = String::New("bar"); |
| 2688 bare_name = String::New("foo"); |
| 2689 EXPECT(!MatchesIgnorePrivate(munged_name, bare_name)); |
| 2690 |
| 2691 munged_name = String::New("foo."); |
| 2692 bare_name = String::New("foo."); |
| 2693 EXPECT(!MatchesIgnorePrivate(munged_name, bare_name)); |
| 2694 |
| 2695 munged_name = String::New("foo.named"); |
| 2696 bare_name = String::New("foo.named"); |
| 2697 EXPECT(!MatchesIgnorePrivate(munged_name, bare_name)); |
| 2698 |
| 2699 // Private match. |
| 2700 munged_name = String::New("foo@12345"); |
| 2701 bare_name = String::New("foo"); |
| 2702 EXPECT(MatchesIgnorePrivate(munged_name, bare_name)); |
| 2703 |
| 2704 // Private mismatch. |
| 2705 munged_name = String::New("food@12345"); |
| 2706 bare_name = String::New("foo"); |
| 2707 EXPECT(!MatchesIgnorePrivate(munged_name, bare_name)); |
| 2708 |
| 2709 // Private mismatch 2. |
| 2710 munged_name = String::New("foo@12345"); |
| 2711 bare_name = String::New("food"); |
| 2712 EXPECT(!MatchesIgnorePrivate(munged_name, bare_name)); |
| 2713 |
| 2714 // Private constructor match. |
| 2715 munged_name = String::New("foo@12345."); |
| 2716 bare_name = String::New("foo."); |
| 2717 EXPECT(MatchesIgnorePrivate(munged_name, bare_name)); |
| 2718 |
| 2719 // Private constructor mismatch. |
| 2720 munged_name = String::New("foo@12345."); |
| 2721 bare_name = String::New("foo"); |
| 2722 EXPECT(!MatchesIgnorePrivate(munged_name, bare_name)); |
| 2723 |
| 2724 // Private constructor mismatch 2. |
| 2725 munged_name = String::New("foo@12345"); |
| 2726 bare_name = String::New("foo."); |
| 2727 EXPECT(!MatchesIgnorePrivate(munged_name, bare_name)); |
| 2728 |
| 2729 // Named private constructor match. |
| 2730 munged_name = String::New("foo@12345.named"); |
| 2731 bare_name = String::New("foo.named"); |
| 2732 EXPECT(MatchesIgnorePrivate(munged_name, bare_name)); |
| 2733 |
| 2734 // Named private constructor mismatch. |
| 2735 munged_name = String::New("foo@12345.name"); |
| 2736 bare_name = String::New("foo.named"); |
| 2737 EXPECT(!MatchesIgnorePrivate(munged_name, bare_name)); |
| 2738 |
| 2739 // Named private constructor mismatch 2. |
| 2740 munged_name = String::New("foo@12345.named"); |
| 2741 bare_name = String::New("foo.name"); |
| 2742 EXPECT(!MatchesIgnorePrivate(munged_name, bare_name)); |
| 2743 |
| 2744 // Named double-private constructor match. Yes, this happens. |
| 2745 munged_name = String::New("foo@12345.named@12345"); |
| 2746 bare_name = String::New("foo.named"); |
| 2747 EXPECT(MatchesIgnorePrivate(munged_name, bare_name)); |
| 2748 |
| 2749 // Named double-private constructor mismatch. |
| 2750 munged_name = String::New("foo@12345.name@12345"); |
| 2751 bare_name = String::New("foo.named"); |
| 2752 EXPECT(!MatchesIgnorePrivate(munged_name, bare_name)); |
| 2753 |
| 2754 // Named double-private constructor mismatch. |
| 2755 munged_name = String::New("foo@12345.named@12345"); |
| 2756 bare_name = String::New("foo.name"); |
| 2757 EXPECT(!MatchesIgnorePrivate(munged_name, bare_name)); |
| 2758 } |
| 2759 |
| 2760 |
2673 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 2761 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
2674 | 2762 |
2675 } // namespace dart | 2763 } // namespace dart |
OLD | NEW |