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/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 String& cat = String::Handle(Symbols::FromCharCode(kCatFaceWithTearsOfJoy)); | 1606 String& cat = String::Handle(Symbols::FromCharCode(kCatFaceWithTearsOfJoy)); |
1607 | 1607 |
1608 uint16_t cat_utf16[] = { 0xd83d, 0xde39 }; | 1608 uint16_t cat_utf16[] = { 0xd83d, 0xde39 }; |
1609 String& cat2 = String::Handle(Symbols::FromUTF16(cat_utf16, 2)); | 1609 String& cat2 = String::Handle(Symbols::FromUTF16(cat_utf16, 2)); |
1610 EXPECT(cat2.IsSymbol()); | 1610 EXPECT(cat2.IsSymbol()); |
1611 EXPECT_EQ(cat2.raw(), cat.raw()); | 1611 EXPECT_EQ(cat2.raw(), cat.raw()); |
1612 } | 1612 } |
1613 | 1613 |
1614 | 1614 |
1615 TEST_CASE(Bool) { | 1615 TEST_CASE(Bool) { |
1616 const Bool& true_value = Bool::Handle(Bool::True()); | 1616 EXPECT(Bool::True().value()); |
1617 EXPECT(true_value.value()); | 1617 EXPECT(!Bool::False().value()); |
1618 const Bool& false_value = Bool::Handle(Bool::False()); | |
1619 EXPECT(!false_value.value()); | |
1620 } | 1618 } |
1621 | 1619 |
1622 | 1620 |
1623 TEST_CASE(Array) { | 1621 TEST_CASE(Array) { |
1624 const int kArrayLen = 5; | 1622 const int kArrayLen = 5; |
1625 const Array& array = Array::Handle(Array::New(kArrayLen)); | 1623 const Array& array = Array::Handle(Array::New(kArrayLen)); |
1626 EXPECT_EQ(kArrayLen, array.Length()); | 1624 EXPECT_EQ(kArrayLen, array.Length()); |
1627 Object& element = Object::Handle(array.At(0)); | 1625 Object& element = Object::Handle(array.At(0)); |
1628 EXPECT(element.IsNull()); | 1626 EXPECT(element.IsNull()); |
1629 element = array.At(kArrayLen - 1); | 1627 element = array.At(kArrayLen - 1); |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2536 TEST_CASE(ObjectPrinting) { | 2534 TEST_CASE(ObjectPrinting) { |
2537 // Simple Smis. | 2535 // Simple Smis. |
2538 EXPECT_STREQ("2", Smi::Handle(Smi::New(2)).ToCString()); | 2536 EXPECT_STREQ("2", Smi::Handle(Smi::New(2)).ToCString()); |
2539 EXPECT_STREQ("-15", Smi::Handle(Smi::New(-15)).ToCString()); | 2537 EXPECT_STREQ("-15", Smi::Handle(Smi::New(-15)).ToCString()); |
2540 | 2538 |
2541 // bool class and true/false values. | 2539 // bool class and true/false values. |
2542 ObjectStore* object_store = Isolate::Current()->object_store(); | 2540 ObjectStore* object_store = Isolate::Current()->object_store(); |
2543 const Class& bool_class = Class::Handle(object_store->bool_class()); | 2541 const Class& bool_class = Class::Handle(object_store->bool_class()); |
2544 EXPECT_STREQ("Library:'dart:core' Class: bool", | 2542 EXPECT_STREQ("Library:'dart:core' Class: bool", |
2545 bool_class.ToCString()); | 2543 bool_class.ToCString()); |
2546 EXPECT_STREQ("true", Bool::Handle(Bool::True()).ToCString()); | 2544 EXPECT_STREQ("true", Bool::True().ToCString()); |
2547 EXPECT_STREQ("false", Bool::Handle(Bool::False()).ToCString()); | 2545 EXPECT_STREQ("false", Bool::False().ToCString()); |
2548 | 2546 |
2549 // Strings. | 2547 // Strings. |
2550 EXPECT_STREQ("Sugarbowl", | 2548 EXPECT_STREQ("Sugarbowl", |
2551 String::Handle(String::New("Sugarbowl")).ToCString()); | 2549 String::Handle(String::New("Sugarbowl")).ToCString()); |
2552 } | 2550 } |
2553 | 2551 |
2554 | 2552 |
2555 TEST_CASE(CheckedHandle) { | 2553 TEST_CASE(CheckedHandle) { |
2556 // Ensure that null handles have the correct C++ vtable setup. | 2554 // Ensure that null handles have the correct C++ vtable setup. |
2557 const String& str1 = String::Handle(); | 2555 const String& str1 = String::Handle(); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2839 TEST_CASE(SubtypeTestCache) { | 2837 TEST_CASE(SubtypeTestCache) { |
2840 String& class_name = String::Handle(Symbols::New("EmptyClass")); | 2838 String& class_name = String::Handle(Symbols::New("EmptyClass")); |
2841 Script& script = Script::Handle(); | 2839 Script& script = Script::Handle(); |
2842 const Class& empty_class = | 2840 const Class& empty_class = |
2843 Class::Handle(Class::New(class_name, script, Scanner::kDummyTokenIndex)); | 2841 Class::Handle(Class::New(class_name, script, Scanner::kDummyTokenIndex)); |
2844 SubtypeTestCache& cache = SubtypeTestCache::Handle(SubtypeTestCache::New()); | 2842 SubtypeTestCache& cache = SubtypeTestCache::Handle(SubtypeTestCache::New()); |
2845 ASSERT(!cache.IsNull()); | 2843 ASSERT(!cache.IsNull()); |
2846 EXPECT_EQ(0, cache.NumberOfChecks()); | 2844 EXPECT_EQ(0, cache.NumberOfChecks()); |
2847 const TypeArguments& targ_0 = TypeArguments::Handle(TypeArguments::New(2)); | 2845 const TypeArguments& targ_0 = TypeArguments::Handle(TypeArguments::New(2)); |
2848 const TypeArguments& targ_1 = TypeArguments::Handle(TypeArguments::New(3)); | 2846 const TypeArguments& targ_1 = TypeArguments::Handle(TypeArguments::New(3)); |
2849 cache.AddCheck(empty_class.id(), targ_0, targ_1, Bool::Handle(Bool::True())); | 2847 cache.AddCheck(empty_class.id(), targ_0, targ_1, Bool::True()); |
2850 EXPECT_EQ(1, cache.NumberOfChecks()); | 2848 EXPECT_EQ(1, cache.NumberOfChecks()); |
2851 intptr_t test_class_id = -1; | 2849 intptr_t test_class_id = -1; |
2852 AbstractTypeArguments& test_targ_0 = AbstractTypeArguments::Handle(); | 2850 AbstractTypeArguments& test_targ_0 = AbstractTypeArguments::Handle(); |
2853 AbstractTypeArguments& test_targ_1 = AbstractTypeArguments::Handle(); | 2851 AbstractTypeArguments& test_targ_1 = AbstractTypeArguments::Handle(); |
2854 Bool& test_result = Bool::Handle(); | 2852 Bool& test_result = Bool::Handle(); |
2855 cache.GetCheck(0, &test_class_id, &test_targ_0, &test_targ_1, &test_result); | 2853 cache.GetCheck(0, &test_class_id, &test_targ_0, &test_targ_1, &test_result); |
2856 EXPECT_EQ(empty_class.id(), test_class_id); | 2854 EXPECT_EQ(empty_class.id(), test_class_id); |
2857 EXPECT_EQ(targ_0.raw(), test_targ_0.raw()); | 2855 EXPECT_EQ(targ_0.raw(), test_targ_0.raw()); |
2858 EXPECT_EQ(targ_1.raw(), test_targ_1.raw()); | 2856 EXPECT_EQ(targ_1.raw(), test_targ_1.raw()); |
2859 EXPECT_EQ(Bool::True(), test_result.raw()); | 2857 EXPECT_EQ(Bool::True().raw(), test_result.raw()); |
2860 } | 2858 } |
2861 | 2859 |
2862 | 2860 |
2863 TEST_CASE(FieldTests) { | 2861 TEST_CASE(FieldTests) { |
2864 const String& f = String::Handle(String::New("oneField")); | 2862 const String& f = String::Handle(String::New("oneField")); |
2865 const String& getter_f = String::Handle(Field::GetterName(f)); | 2863 const String& getter_f = String::Handle(Field::GetterName(f)); |
2866 const String& setter_f = String::Handle(Field::SetterName(f)); | 2864 const String& setter_f = String::Handle(Field::SetterName(f)); |
2867 EXPECT(!Field::IsGetterName(f)); | 2865 EXPECT(!Field::IsGetterName(f)); |
2868 EXPECT(!Field::IsSetterName(f)); | 2866 EXPECT(!Field::IsSetterName(f)); |
2869 EXPECT(Field::IsGetterName(getter_f)); | 2867 EXPECT(Field::IsGetterName(getter_f)); |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3481 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint()); | 3479 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint()); |
3482 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint()); | 3480 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint()); |
3483 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint()); | 3481 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint()); |
3484 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint()); | 3482 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint()); |
3485 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint()); | 3483 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint()); |
3486 } | 3484 } |
3487 | 3485 |
3488 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 3486 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
3489 | 3487 |
3490 } // namespace dart | 3488 } // namespace dart |
OLD | NEW |