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 "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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 } | 511 } |
512 } | 512 } |
513 | 513 |
514 | 514 |
515 TEST_CASE(IsString) { | 515 TEST_CASE(IsString) { |
516 uint8_t data8[] = { 'o', 'n', 'e', 0x7F }; | 516 uint8_t data8[] = { 'o', 'n', 'e', 0x7F }; |
517 | 517 |
518 Dart_Handle str8 = Dart_NewStringFromUTF8(data8, ARRAY_SIZE(data8)); | 518 Dart_Handle str8 = Dart_NewStringFromUTF8(data8, ARRAY_SIZE(data8)); |
519 EXPECT_VALID(str8); | 519 EXPECT_VALID(str8); |
520 EXPECT(Dart_IsString(str8)); | 520 EXPECT(Dart_IsString(str8)); |
521 EXPECT(Dart_IsAsciiString(str8)); | 521 EXPECT(Dart_IsISOLatin1String(str8)); |
522 EXPECT(!Dart_IsExternalString(str8)); | 522 EXPECT(!Dart_IsExternalString(str8)); |
523 | 523 |
524 Dart_Handle ext8 = Dart_NewExternalUTF8String(data8, ARRAY_SIZE(data8), | 524 Dart_Handle ext8 = Dart_NewExternalUTF8String(data8, ARRAY_SIZE(data8), |
525 NULL, NULL); | 525 NULL, NULL); |
526 EXPECT_VALID(ext8); | 526 EXPECT_VALID(ext8); |
527 EXPECT(Dart_IsString(ext8)); | 527 EXPECT(Dart_IsString(ext8)); |
528 EXPECT(Dart_IsExternalString(ext8)); | 528 EXPECT(Dart_IsExternalString(ext8)); |
529 | 529 |
530 uint16_t data16[] = { 't', 'w', 'o', 0xFFFF }; | 530 uint16_t data16[] = { 't', 'w', 'o', 0xFFFF }; |
531 | 531 |
532 Dart_Handle str16 = Dart_NewStringFromUTF16(data16, ARRAY_SIZE(data16)); | 532 Dart_Handle str16 = Dart_NewStringFromUTF16(data16, ARRAY_SIZE(data16)); |
533 EXPECT_VALID(str16); | 533 EXPECT_VALID(str16); |
534 EXPECT(Dart_IsString(str16)); | 534 EXPECT(Dart_IsString(str16)); |
535 EXPECT(!Dart_IsAsciiString(str16)); | 535 EXPECT(!Dart_IsISOLatin1String(str16)); |
536 EXPECT(!Dart_IsExternalString(str16)); | 536 EXPECT(!Dart_IsExternalString(str16)); |
537 | 537 |
538 Dart_Handle ext16 = Dart_NewExternalUTF16String(data16, ARRAY_SIZE(data16), | 538 Dart_Handle ext16 = Dart_NewExternalUTF16String(data16, ARRAY_SIZE(data16), |
539 NULL, NULL); | 539 NULL, NULL); |
540 EXPECT_VALID(ext16); | 540 EXPECT_VALID(ext16); |
541 EXPECT(Dart_IsString(ext16)); | 541 EXPECT(Dart_IsString(ext16)); |
542 EXPECT(Dart_IsExternalString(ext16)); | 542 EXPECT(Dart_IsExternalString(ext16)); |
543 | 543 |
544 uint32_t data32[] = { 'f', 'o', 'u', 'r', 0x10FFFF }; | 544 uint32_t data32[] = { 'f', 'o', 'u', 'r', 0x10FFFF }; |
545 | 545 |
(...skipping 6612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7158 EXPECT(o2 == reinterpret_cast<void*>(&p2)); | 7158 EXPECT(o2 == reinterpret_cast<void*>(&p2)); |
7159 } | 7159 } |
7160 Dart_ExitScope(); | 7160 Dart_ExitScope(); |
7161 isolate->heap()->CollectGarbage(Heap::kOld); | 7161 isolate->heap()->CollectGarbage(Heap::kOld); |
7162 EXPECT_EQ(0, isolate->heap()->PeerCount()); | 7162 EXPECT_EQ(0, isolate->heap()->PeerCount()); |
7163 } | 7163 } |
7164 | 7164 |
7165 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 7165 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
7166 | 7166 |
7167 } // namespace dart | 7167 } // namespace dart |
OLD | NEW |