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_debugger_api.h" | 5 #include "include/dart_debugger_api.h" |
6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
8 #include "vm/unit_test.h" | 8 #include "vm/unit_test.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 | 968 |
969 Dart_Handle lib_url = Dart_NewString(TestCase::url()); | 969 Dart_Handle lib_url = Dart_NewString(TestCase::url()); |
970 Dart_Handle source = Dart_GetScriptSource(lib_url, lib_url); | 970 Dart_Handle source = Dart_GetScriptSource(lib_url, lib_url); |
971 EXPECT(Dart_IsString(source)); | 971 EXPECT(Dart_IsString(source)); |
972 char const* source_chars; | 972 char const* source_chars; |
973 Dart_StringToCString(source, &source_chars); | 973 Dart_StringToCString(source, &source_chars); |
974 OS::Print("\n=== source: ===\n%s", source_chars); | 974 OS::Print("\n=== source: ===\n%s", source_chars); |
975 EXPECT_STREQ(kScriptChars, source_chars); | 975 EXPECT_STREQ(kScriptChars, source_chars); |
976 } | 976 } |
977 | 977 |
| 978 |
| 979 TEST_CASE(GetLibraryURLs) { |
| 980 const char* kScriptChars = |
| 981 "main() {" |
| 982 " return 12345;" |
| 983 "}"; |
| 984 |
| 985 Dart_Handle lib_list = Dart_GetLibraryURLs(); |
| 986 EXPECT_VALID(lib_list); |
| 987 EXPECT(Dart_IsList(lib_list)); |
| 988 Dart_Handle list_as_string = Dart_ToString(lib_list); |
| 989 const char* list_cstr = ""; |
| 990 EXPECT_VALID(Dart_StringToCString(list_as_string, &list_cstr)); |
| 991 EXPECT_NOTSUBSTRING(TestCase::url(), list_cstr); |
| 992 |
| 993 // Load a script. |
| 994 Dart_Handle url = Dart_NewString(TestCase::url()); |
| 995 Dart_Handle source = Dart_NewString(kScriptChars); |
| 996 EXPECT_VALID(Dart_LoadScript(url, source)); |
| 997 |
| 998 lib_list = Dart_GetLibraryURLs(); |
| 999 EXPECT_VALID(lib_list); |
| 1000 EXPECT(Dart_IsList(lib_list)); |
| 1001 list_as_string = Dart_ToString(lib_list); |
| 1002 list_cstr = ""; |
| 1003 EXPECT_VALID(Dart_StringToCString(list_as_string, &list_cstr)); |
| 1004 EXPECT_SUBSTRING(TestCase::url(), list_cstr); |
| 1005 } |
| 1006 |
| 1007 |
978 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 1008 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
979 | 1009 |
980 } // namespace dart | 1010 } // namespace dart |
OLD | NEW |