| 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 "include/dart_api.h" | 6 #include "include/dart_api.h" |
| 7 #include "include/dart_debugger_api.h" |
| 7 #include "include/dart_mirrors_api.h" | 8 #include "include/dart_mirrors_api.h" |
| 8 #include "include/dart_native_api.h" | 9 #include "include/dart_native_api.h" |
| 9 #include "platform/assert.h" | 10 #include "platform/assert.h" |
| 10 #include "platform/json.h" | 11 #include "platform/json.h" |
| 11 #include "platform/utils.h" | 12 #include "platform/utils.h" |
| 12 #include "vm/class_finalizer.h" | 13 #include "vm/class_finalizer.h" |
| 13 #include "vm/dart_api_impl.h" | 14 #include "vm/dart_api_impl.h" |
| 14 #include "vm/dart_api_state.h" | 15 #include "vm/dart_api_state.h" |
| 15 #include "vm/thread.h" | 16 #include "vm/thread.h" |
| 16 #include "vm/unit_test.h" | 17 #include "vm/unit_test.h" |
| (...skipping 4816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4833 EXPECT_STREQ("incoming error", Dart_GetError(result)); | 4834 EXPECT_STREQ("incoming error", Dart_GetError(result)); |
| 4834 | 4835 |
| 4835 result = Dart_LibraryName(lib); | 4836 result = Dart_LibraryName(lib); |
| 4836 EXPECT_VALID(result); | 4837 EXPECT_VALID(result); |
| 4837 EXPECT(Dart_IsString(result)); | 4838 EXPECT(Dart_IsString(result)); |
| 4838 const char* cstr = NULL; | 4839 const char* cstr = NULL; |
| 4839 EXPECT_VALID(Dart_StringToCString(result, &cstr)); | 4840 EXPECT_VALID(Dart_StringToCString(result, &cstr)); |
| 4840 EXPECT_STREQ("library1_name", cstr); | 4841 EXPECT_STREQ("library1_name", cstr); |
| 4841 } | 4842 } |
| 4842 | 4843 |
| 4844 TEST_CASE(LibraryId) { |
| 4845 const char* kLibrary1Chars = |
| 4846 "library library1_name;"; |
| 4847 Dart_Handle url = NewString("library1_url"); |
| 4848 Dart_Handle source = NewString(kLibrary1Chars); |
| 4849 Dart_Handle lib = Dart_LoadLibrary(url, source); |
| 4850 Dart_Handle error = Dart_NewApiError("incoming error"); |
| 4851 EXPECT_VALID(lib); |
| 4852 intptr_t libraryId = -1; |
| 4853 |
| 4854 Dart_Handle result = Dart_LibraryId(Dart_Null(), &libraryId); |
| 4855 EXPECT(Dart_IsError(result)); |
| 4856 EXPECT_STREQ("Dart_LibraryId expects argument 'library' to be non-null.", |
| 4857 Dart_GetError(result)); |
| 4858 |
| 4859 result = Dart_LibraryId(Dart_True(), &libraryId); |
| 4860 EXPECT(Dart_IsError(result)); |
| 4861 EXPECT_STREQ( |
| 4862 "Dart_LibraryId expects argument 'library' to be of type Library.", |
| 4863 Dart_GetError(result)); |
| 4864 |
| 4865 result = Dart_LibraryId(error, &libraryId); |
| 4866 EXPECT(Dart_IsError(result)); |
| 4867 EXPECT_STREQ("incoming error", Dart_GetError(result)); |
| 4868 |
| 4869 result = Dart_LibraryId(lib, &libraryId); |
| 4870 EXPECT_VALID(result); |
| 4871 Dart_Handle libFromId = Dart_GetLibraryFromId(libraryId); |
| 4872 EXPECT(Dart_IsLibrary(libFromId)); |
| 4873 result = Dart_LibraryName(libFromId); |
| 4874 EXPECT(Dart_IsString(result)); |
| 4875 const char* cstr = NULL; |
| 4876 EXPECT_VALID(Dart_StringToCString(result, &cstr)); |
| 4877 EXPECT_STREQ("library1_name", cstr); |
| 4878 } |
| 4879 |
| 4843 | 4880 |
| 4844 TEST_CASE(LibraryUrl) { | 4881 TEST_CASE(LibraryUrl) { |
| 4845 const char* kLibrary1Chars = | 4882 const char* kLibrary1Chars = |
| 4846 "library library1_name;"; | 4883 "library library1_name;"; |
| 4847 Dart_Handle url = NewString("library1_url"); | 4884 Dart_Handle url = NewString("library1_url"); |
| 4848 Dart_Handle source = NewString(kLibrary1Chars); | 4885 Dart_Handle source = NewString(kLibrary1Chars); |
| 4849 Dart_Handle lib = Dart_LoadLibrary(url, source); | 4886 Dart_Handle lib = Dart_LoadLibrary(url, source); |
| 4850 Dart_Handle error = Dart_NewApiError("incoming error"); | 4887 Dart_Handle error = Dart_NewApiError("incoming error"); |
| 4851 EXPECT_VALID(lib); | 4888 EXPECT_VALID(lib); |
| 4852 | 4889 |
| (...skipping 2507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7360 NewString("main"), | 7397 NewString("main"), |
| 7361 0, | 7398 0, |
| 7362 NULL); | 7399 NULL); |
| 7363 int64_t value = 0; | 7400 int64_t value = 0; |
| 7364 result = Dart_IntegerToInt64(result, &value); | 7401 result = Dart_IntegerToInt64(result, &value); |
| 7365 EXPECT_VALID(result); | 7402 EXPECT_VALID(result); |
| 7366 EXPECT_EQ(8, value); | 7403 EXPECT_EQ(8, value); |
| 7367 } | 7404 } |
| 7368 | 7405 |
| 7369 } // namespace dart | 7406 } // namespace dart |
| OLD | NEW |