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 "bin/builtin.h" | 5 #include "bin/builtin.h" |
6 #include "vm/compiler.h" | 6 #include "vm/compiler.h" |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "include/dart_mirrors_api.h" | 8 #include "include/dart_mirrors_api.h" |
9 #include "include/dart_native_api.h" | 9 #include "include/dart_native_api.h" |
10 #include "include/dart_tools_api.h" | 10 #include "include/dart_tools_api.h" |
(...skipping 8554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8565 EXPECT(Dart_IsString(empty_str)); | 8565 EXPECT(Dart_IsString(empty_str)); |
8566 EXPECT(Dart_IsStringLatin1(str)); | 8566 EXPECT(Dart_IsStringLatin1(str)); |
8567 EXPECT(Dart_IsStringLatin1(empty_str)); | 8567 EXPECT(Dart_IsStringLatin1(empty_str)); |
8568 EXPECT(Dart_IsExternalString(str)); | 8568 EXPECT(Dart_IsExternalString(str)); |
8569 EXPECT(Dart_IsExternalString(empty_str)); | 8569 EXPECT(Dart_IsExternalString(empty_str)); |
8570 EXPECT_VALID(Dart_StringLength(str, &length)); | 8570 EXPECT_VALID(Dart_StringLength(str, &length)); |
8571 EXPECT_EQ(0, length); | 8571 EXPECT_EQ(0, length); |
8572 | 8572 |
8573 // Test with single character canonical string, it should not become | 8573 // Test with single character canonical string, it should not become |
8574 // external string but the peer should be setup for it. | 8574 // external string but the peer should be setup for it. |
8575 Dart_Handle canonical_str = Api::NewHandle(thread, Symbols::New("*")); | 8575 Dart_Handle canonical_str = Api::NewHandle(thread, Symbols::New(thread, |
| 8576 "*")); |
8576 EXPECT(Dart_IsString(canonical_str)); | 8577 EXPECT(Dart_IsString(canonical_str)); |
8577 EXPECT(!Dart_IsExternalString(canonical_str)); | 8578 EXPECT(!Dart_IsExternalString(canonical_str)); |
8578 uint8_t ext_canonical_str[kLength]; | 8579 uint8_t ext_canonical_str[kLength]; |
8579 str = Dart_MakeExternalString(canonical_str, | 8580 str = Dart_MakeExternalString(canonical_str, |
8580 ext_canonical_str, | 8581 ext_canonical_str, |
8581 kLength, | 8582 kLength, |
8582 &canonical_str_peer, | 8583 &canonical_str_peer, |
8583 MakeExternalCback); | 8584 MakeExternalCback); |
8584 EXPECT(Dart_IsString(str)); | 8585 EXPECT(Dart_IsString(str)); |
8585 EXPECT(!Dart_IsExternalString(canonical_str)); | 8586 EXPECT(!Dart_IsExternalString(canonical_str)); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8655 EXPECT_EQ(expected_length, length); | 8656 EXPECT_EQ(expected_length, length); |
8656 EXPECT(Dart_IdentityEquals(str, utf16_str)); | 8657 EXPECT(Dart_IdentityEquals(str, utf16_str)); |
8657 for (intptr_t i = 0; i < length; i++) { | 8658 for (intptr_t i = 0; i < length; i++) { |
8658 EXPECT_EQ(0x4e8c, ext_utf16_str[i]); | 8659 EXPECT_EQ(0x4e8c, ext_utf16_str[i]); |
8659 } | 8660 } |
8660 | 8661 |
8661 Zone* zone = thread->zone(); | 8662 Zone* zone = thread->zone(); |
8662 // Test with a symbol (hash value should be preserved on externalization). | 8663 // Test with a symbol (hash value should be preserved on externalization). |
8663 const char* symbol_ascii = "?unseen"; | 8664 const char* symbol_ascii = "?unseen"; |
8664 expected_length = strlen(symbol_ascii); | 8665 expected_length = strlen(symbol_ascii); |
8665 Dart_Handle symbol_str = | 8666 Dart_Handle symbol_str = Api::NewHandle(thread, |
8666 Api::NewHandle(thread, Symbols::New(symbol_ascii, expected_length)); | 8667 Symbols::New(thread, symbol_ascii, expected_length)); |
8667 EXPECT_VALID(symbol_str); | 8668 EXPECT_VALID(symbol_str); |
8668 EXPECT(Dart_IsString(symbol_str)); | 8669 EXPECT(Dart_IsString(symbol_str)); |
8669 EXPECT(Dart_IsStringLatin1(symbol_str)); | 8670 EXPECT(Dart_IsStringLatin1(symbol_str)); |
8670 EXPECT(!Dart_IsExternalString(symbol_str)); | 8671 EXPECT(!Dart_IsExternalString(symbol_str)); |
8671 EXPECT_VALID(Dart_StringLength(symbol_str, &length)); | 8672 EXPECT_VALID(Dart_StringLength(symbol_str, &length)); |
8672 EXPECT_EQ(expected_length, length); | 8673 EXPECT_EQ(expected_length, length); |
8673 EXPECT(Api::UnwrapStringHandle(zone, symbol_str).HasHash()); | 8674 EXPECT(Api::UnwrapStringHandle(zone, symbol_str).HasHash()); |
8674 | 8675 |
8675 uint8_t ext_symbol_ascii[kLength]; | 8676 uint8_t ext_symbol_ascii[kLength]; |
8676 EXPECT_VALID(Dart_StringStorageSize(symbol_str, &size)); | 8677 EXPECT_VALID(Dart_StringStorageSize(symbol_str, &size)); |
(...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10052 result = Dart_Invoke(lib, | 10053 result = Dart_Invoke(lib, |
10053 NewString("foozoo"), | 10054 NewString("foozoo"), |
10054 0, | 10055 0, |
10055 NULL); | 10056 NULL); |
10056 EXPECT(Dart_IsError(result)); | 10057 EXPECT(Dart_IsError(result)); |
10057 } | 10058 } |
10058 | 10059 |
10059 #endif // !PRODUCT | 10060 #endif // !PRODUCT |
10060 | 10061 |
10061 } // namespace dart | 10062 } // namespace dart |
OLD | NEW |