| 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_mirrors_api.h" | 7 #include "include/dart_mirrors_api.h" |
| 8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/json.h" | 10 #include "platform/json.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 EXPECT_VALID(Dart_ErrorGetStacktrace(exception)); | 60 EXPECT_VALID(Dart_ErrorGetStacktrace(exception)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 | 63 |
| 64 TEST_CASE(ErrorHandleTypes) { | 64 TEST_CASE(ErrorHandleTypes) { |
| 65 Isolate* isolate = Isolate::Current(); | 65 Isolate* isolate = Isolate::Current(); |
| 66 const String& compile_message = String::Handle(String::New("CompileError")); | 66 const String& compile_message = String::Handle(String::New("CompileError")); |
| 67 const String& fatal_message = String::Handle(String::New("FatalError")); | 67 const String& fatal_message = String::Handle(String::New("FatalError")); |
| 68 | 68 |
| 69 Dart_Handle not_error = NewString("NotError"); | 69 Dart_Handle not_error = NewString("NotError"); |
| 70 Dart_Handle api_error = Dart_NewApiError("Api%s", "Error"); | 70 Dart_Handle api_error = Api::NewError("Api%s", "Error"); |
| 71 Dart_Handle exception_error = | 71 Dart_Handle exception_error = |
| 72 Dart_NewUnhandledExceptionError(NewString("ExceptionError")); | 72 Dart_NewUnhandledExceptionError(NewString("ExceptionError")); |
| 73 Dart_Handle compile_error = | 73 Dart_Handle compile_error = |
| 74 Api::NewHandle(isolate, LanguageError::New(compile_message)); | 74 Api::NewHandle(isolate, LanguageError::New(compile_message)); |
| 75 Dart_Handle fatal_error = | 75 Dart_Handle fatal_error = |
| 76 Api::NewHandle(isolate, UnwindError::New(fatal_message)); | 76 Api::NewHandle(isolate, UnwindError::New(fatal_message)); |
| 77 | 77 |
| 78 EXPECT_VALID(not_error); | 78 EXPECT_VALID(not_error); |
| 79 EXPECT(Dart_IsError(api_error)); | 79 EXPECT(Dart_IsError(api_error)); |
| 80 EXPECT(Dart_IsError(exception_error)); | 80 EXPECT(Dart_IsError(exception_error)); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 EXPECT_SUBSTRING("semicolon expected", Dart_GetError(result)); | 161 EXPECT_SUBSTRING("semicolon expected", Dart_GetError(result)); |
| 162 | 162 |
| 163 result = Dart_Invoke(lib, NewString("Func2"), 0, NULL); | 163 result = Dart_Invoke(lib, NewString("Func2"), 0, NULL); |
| 164 EXPECT(Dart_IsError(result)); | 164 EXPECT(Dart_IsError(result)); |
| 165 EXPECT(Dart_ErrorHasException(result)); | 165 EXPECT(Dart_ErrorHasException(result)); |
| 166 EXPECT_SUBSTRING("myException", Dart_GetError(result)); | 166 EXPECT_SUBSTRING("myException", Dart_GetError(result)); |
| 167 } | 167 } |
| 168 | 168 |
| 169 | 169 |
| 170 TEST_CASE(Dart_Error) { | 170 TEST_CASE(Dart_Error) { |
| 171 Dart_Handle error = Dart_Error("An %s", "error"); | 171 Dart_Handle error = Api::NewError("An %s", "error"); |
| 172 EXPECT(Dart_IsError(error)); | 172 EXPECT(Dart_IsError(error)); |
| 173 EXPECT_STREQ("An error", Dart_GetError(error)); | 173 EXPECT_STREQ("An error", Dart_GetError(error)); |
| 174 } | 174 } |
| 175 | 175 |
| 176 | 176 |
| 177 TEST_CASE(Null) { | 177 TEST_CASE(Null) { |
| 178 Dart_Handle null = Dart_Null(); | 178 Dart_Handle null = Dart_Null(); |
| 179 EXPECT_VALID(null); | 179 EXPECT_VALID(null); |
| 180 EXPECT(Dart_IsNull(null)); | 180 EXPECT(Dart_IsNull(null)); |
| 181 | 181 |
| (...skipping 3210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3392 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 3392 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 3393 | 3393 |
| 3394 // Invoke a function which returns an object of type NativeFields. | 3394 // Invoke a function which returns an object of type NativeFields. |
| 3395 result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); | 3395 result = Dart_Invoke(lib, NewString("testMain"), 0, NULL); |
| 3396 | 3396 |
| 3397 USE(result); | 3397 USE(result); |
| 3398 #if 0 | 3398 #if 0 |
| 3399 // TODO(12455) Need better validation. | 3399 // TODO(12455) Need better validation. |
| 3400 // We expect the test script to fail finalization with the error below: | 3400 // We expect the test script to fail finalization with the error below: |
| 3401 EXPECT(Dart_IsError(result)); | 3401 EXPECT(Dart_IsError(result)); |
| 3402 Dart_Handle expected_error = Dart_Error( | 3402 Dart_Handle expected_error = DartUtils::NewError( |
| 3403 "'dart:test-lib': Error: line 1 pos 36: " | 3403 "'dart:test-lib': Error: line 1 pos 36: " |
| 3404 "class 'NativeFields' is trying to extend a native fields class, " | 3404 "class 'NativeFields' is trying to extend a native fields class, " |
| 3405 "but library '%s' has no native resolvers", | 3405 "but library '%s' has no native resolvers", |
| 3406 TestCase::url()); | 3406 TestCase::url()); |
| 3407 EXPECT_SUBSTRING(Dart_GetError(expected_error), Dart_GetError(result)); | 3407 EXPECT_SUBSTRING(Dart_GetError(expected_error), Dart_GetError(result)); |
| 3408 #endif | 3408 #endif |
| 3409 } | 3409 } |
| 3410 | 3410 |
| 3411 | 3411 |
| 3412 TEST_CASE(InjectNativeFieldsSuperClass) { | 3412 TEST_CASE(InjectNativeFieldsSuperClass) { |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3823 "}\n"; | 3823 "}\n"; |
| 3824 | 3824 |
| 3825 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 3825 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 3826 Dart_Handle type = Dart_GetType(lib, NewString("MyClass"), 0, NULL); | 3826 Dart_Handle type = Dart_GetType(lib, NewString("MyClass"), 0, NULL); |
| 3827 EXPECT_VALID(type); | 3827 EXPECT_VALID(type); |
| 3828 Dart_Handle intf = Dart_GetType(lib, NewString("MyInterface"), 0, NULL); | 3828 Dart_Handle intf = Dart_GetType(lib, NewString("MyInterface"), 0, NULL); |
| 3829 EXPECT_VALID(intf); | 3829 EXPECT_VALID(intf); |
| 3830 Dart_Handle args[1]; | 3830 Dart_Handle args[1]; |
| 3831 args[0] = Dart_NewInteger(11); | 3831 args[0] = Dart_NewInteger(11); |
| 3832 Dart_Handle bad_args[1]; | 3832 Dart_Handle bad_args[1]; |
| 3833 bad_args[0] = Dart_Error("myerror"); | 3833 bad_args[0] = Dart_NewApiError("myerror"); |
| 3834 | 3834 |
| 3835 // Invoke the unnamed constructor. | 3835 // Invoke the unnamed constructor. |
| 3836 Dart_Handle result = Dart_New(type, Dart_Null(), 0, NULL); | 3836 Dart_Handle result = Dart_New(type, Dart_Null(), 0, NULL); |
| 3837 EXPECT_VALID(result); | 3837 EXPECT_VALID(result); |
| 3838 bool instanceof = false; | 3838 bool instanceof = false; |
| 3839 EXPECT_VALID(Dart_ObjectIsType(result, type, &instanceof)); | 3839 EXPECT_VALID(Dart_ObjectIsType(result, type, &instanceof)); |
| 3840 EXPECT(instanceof); | 3840 EXPECT(instanceof); |
| 3841 int64_t int_value = 0; | 3841 int64_t int_value = 0; |
| 3842 Dart_Handle foo = Dart_GetField(result, NewString("foo")); | 3842 Dart_Handle foo = Dart_GetField(result, NewString("foo")); |
| 3843 EXPECT_VALID(Dart_IntegerToInt64(foo, &int_value)); | 3843 EXPECT_VALID(Dart_IntegerToInt64(foo, &int_value)); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3940 foo = Dart_GetField(result, NewString("foo")); | 3940 foo = Dart_GetField(result, NewString("foo")); |
| 3941 EXPECT_VALID(Dart_IntegerToInt64(foo, &int_value)); | 3941 EXPECT_VALID(Dart_IntegerToInt64(foo, &int_value)); |
| 3942 EXPECT_EQ(1100, int_value); | 3942 EXPECT_EQ(1100, int_value); |
| 3943 | 3943 |
| 3944 // Invoke a factory constructor which returns null. | 3944 // Invoke a factory constructor which returns null. |
| 3945 result = Dart_New(type, NewString("nullo"), 0, NULL); | 3945 result = Dart_New(type, NewString("nullo"), 0, NULL); |
| 3946 EXPECT_VALID(result); | 3946 EXPECT_VALID(result); |
| 3947 EXPECT(Dart_IsNull(result)); | 3947 EXPECT(Dart_IsNull(result)); |
| 3948 | 3948 |
| 3949 // Pass an error class object. Error is passed through. | 3949 // Pass an error class object. Error is passed through. |
| 3950 result = Dart_New(Dart_Error("myerror"), NewString("named"), 1, args); | 3950 result = Dart_New(Dart_NewApiError("myerror"), NewString("named"), 1, args); |
| 3951 EXPECT_ERROR(result, "myerror"); | 3951 EXPECT_ERROR(result, "myerror"); |
| 3952 | 3952 |
| 3953 // Pass a bad class object. | 3953 // Pass a bad class object. |
| 3954 result = Dart_New(Dart_Null(), NewString("named"), 1, args); | 3954 result = Dart_New(Dart_Null(), NewString("named"), 1, args); |
| 3955 EXPECT_ERROR(result, "Dart_New expects argument 'type' to be non-null."); | 3955 EXPECT_ERROR(result, "Dart_New expects argument 'type' to be non-null."); |
| 3956 | 3956 |
| 3957 // Pass a negative arg count. | 3957 // Pass a negative arg count. |
| 3958 result = Dart_New(type, NewString("named"), -1, args); | 3958 result = Dart_New(type, NewString("named"), -1, args); |
| 3959 EXPECT_ERROR( | 3959 EXPECT_ERROR( |
| 3960 result, | 3960 result, |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4614 } | 4614 } |
| 4615 | 4615 |
| 4616 | 4616 |
| 4617 TEST_CASE(LoadScript) { | 4617 TEST_CASE(LoadScript) { |
| 4618 const char* kScriptChars = | 4618 const char* kScriptChars = |
| 4619 "main() {" | 4619 "main() {" |
| 4620 " return 12345;" | 4620 " return 12345;" |
| 4621 "}"; | 4621 "}"; |
| 4622 Dart_Handle url = NewString(TestCase::url()); | 4622 Dart_Handle url = NewString(TestCase::url()); |
| 4623 Dart_Handle source = NewString(kScriptChars); | 4623 Dart_Handle source = NewString(kScriptChars); |
| 4624 Dart_Handle error = Dart_Error("incoming error"); | 4624 Dart_Handle error = Dart_NewApiError("incoming error"); |
| 4625 Dart_Handle result; | 4625 Dart_Handle result; |
| 4626 | 4626 |
| 4627 result = Dart_SetLibraryTagHandler(library_handler); | 4627 result = Dart_SetLibraryTagHandler(library_handler); |
| 4628 EXPECT_VALID(result); | 4628 EXPECT_VALID(result); |
| 4629 | 4629 |
| 4630 result = Dart_LoadScript(Dart_Null(), source, 0, 0); | 4630 result = Dart_LoadScript(Dart_Null(), source, 0, 0); |
| 4631 EXPECT(Dart_IsError(result)); | 4631 EXPECT(Dart_IsError(result)); |
| 4632 EXPECT_STREQ("Dart_LoadScript expects argument 'url' to be non-null.", | 4632 EXPECT_STREQ("Dart_LoadScript expects argument 'url' to be non-null.", |
| 4633 Dart_GetError(result)); | 4633 Dart_GetError(result)); |
| 4634 | 4634 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4787 EXPECT(Dart_IsError(result)); | 4787 EXPECT(Dart_IsError(result)); |
| 4788 EXPECT_STREQ("Dart_LookupLibrary expects argument 'url' to be non-null.", | 4788 EXPECT_STREQ("Dart_LookupLibrary expects argument 'url' to be non-null.", |
| 4789 Dart_GetError(result)); | 4789 Dart_GetError(result)); |
| 4790 | 4790 |
| 4791 result = Dart_LookupLibrary(Dart_True()); | 4791 result = Dart_LookupLibrary(Dart_True()); |
| 4792 EXPECT(Dart_IsError(result)); | 4792 EXPECT(Dart_IsError(result)); |
| 4793 EXPECT_STREQ( | 4793 EXPECT_STREQ( |
| 4794 "Dart_LookupLibrary expects argument 'url' to be of type String.", | 4794 "Dart_LookupLibrary expects argument 'url' to be of type String.", |
| 4795 Dart_GetError(result)); | 4795 Dart_GetError(result)); |
| 4796 | 4796 |
| 4797 result = Dart_LookupLibrary(Dart_Error("incoming error")); | 4797 result = Dart_LookupLibrary(Dart_NewApiError("incoming error")); |
| 4798 EXPECT(Dart_IsError(result)); | 4798 EXPECT(Dart_IsError(result)); |
| 4799 EXPECT_STREQ("incoming error", Dart_GetError(result)); | 4799 EXPECT_STREQ("incoming error", Dart_GetError(result)); |
| 4800 | 4800 |
| 4801 url = NewString("noodles.dart"); | 4801 url = NewString("noodles.dart"); |
| 4802 result = Dart_LookupLibrary(url); | 4802 result = Dart_LookupLibrary(url); |
| 4803 EXPECT(Dart_IsError(result)); | 4803 EXPECT(Dart_IsError(result)); |
| 4804 EXPECT_STREQ("Dart_LookupLibrary: library 'noodles.dart' not found.", | 4804 EXPECT_STREQ("Dart_LookupLibrary: library 'noodles.dart' not found.", |
| 4805 Dart_GetError(result)); | 4805 Dart_GetError(result)); |
| 4806 } | 4806 } |
| 4807 | 4807 |
| 4808 | 4808 |
| 4809 TEST_CASE(LibraryName) { | 4809 TEST_CASE(LibraryName) { |
| 4810 const char* kLibrary1Chars = | 4810 const char* kLibrary1Chars = |
| 4811 "library library1_name;"; | 4811 "library library1_name;"; |
| 4812 Dart_Handle url = NewString("library1_url"); | 4812 Dart_Handle url = NewString("library1_url"); |
| 4813 Dart_Handle source = NewString(kLibrary1Chars); | 4813 Dart_Handle source = NewString(kLibrary1Chars); |
| 4814 Dart_Handle lib = Dart_LoadLibrary(url, source); | 4814 Dart_Handle lib = Dart_LoadLibrary(url, source); |
| 4815 Dart_Handle error = Dart_Error("incoming error"); | 4815 Dart_Handle error = Dart_NewApiError("incoming error"); |
| 4816 EXPECT_VALID(lib); | 4816 EXPECT_VALID(lib); |
| 4817 | 4817 |
| 4818 Dart_Handle result = Dart_LibraryName(Dart_Null()); | 4818 Dart_Handle result = Dart_LibraryName(Dart_Null()); |
| 4819 EXPECT(Dart_IsError(result)); | 4819 EXPECT(Dart_IsError(result)); |
| 4820 EXPECT_STREQ("Dart_LibraryName expects argument 'library' to be non-null.", | 4820 EXPECT_STREQ("Dart_LibraryName expects argument 'library' to be non-null.", |
| 4821 Dart_GetError(result)); | 4821 Dart_GetError(result)); |
| 4822 | 4822 |
| 4823 result = Dart_LibraryName(Dart_True()); | 4823 result = Dart_LibraryName(Dart_True()); |
| 4824 EXPECT(Dart_IsError(result)); | 4824 EXPECT(Dart_IsError(result)); |
| 4825 EXPECT_STREQ( | 4825 EXPECT_STREQ( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4838 EXPECT_STREQ("library1_name", cstr); | 4838 EXPECT_STREQ("library1_name", cstr); |
| 4839 } | 4839 } |
| 4840 | 4840 |
| 4841 | 4841 |
| 4842 TEST_CASE(LibraryUrl) { | 4842 TEST_CASE(LibraryUrl) { |
| 4843 const char* kLibrary1Chars = | 4843 const char* kLibrary1Chars = |
| 4844 "library library1_name;"; | 4844 "library library1_name;"; |
| 4845 Dart_Handle url = NewString("library1_url"); | 4845 Dart_Handle url = NewString("library1_url"); |
| 4846 Dart_Handle source = NewString(kLibrary1Chars); | 4846 Dart_Handle source = NewString(kLibrary1Chars); |
| 4847 Dart_Handle lib = Dart_LoadLibrary(url, source); | 4847 Dart_Handle lib = Dart_LoadLibrary(url, source); |
| 4848 Dart_Handle error = Dart_Error("incoming error"); | 4848 Dart_Handle error = Dart_NewApiError("incoming error"); |
| 4849 EXPECT_VALID(lib); | 4849 EXPECT_VALID(lib); |
| 4850 | 4850 |
| 4851 Dart_Handle result = Dart_LibraryUrl(Dart_Null()); | 4851 Dart_Handle result = Dart_LibraryUrl(Dart_Null()); |
| 4852 EXPECT(Dart_IsError(result)); | 4852 EXPECT(Dart_IsError(result)); |
| 4853 EXPECT_STREQ("Dart_LibraryUrl expects argument 'library' to be non-null.", | 4853 EXPECT_STREQ("Dart_LibraryUrl expects argument 'library' to be non-null.", |
| 4854 Dart_GetError(result)); | 4854 Dart_GetError(result)); |
| 4855 | 4855 |
| 4856 result = Dart_LibraryUrl(Dart_True()); | 4856 result = Dart_LibraryUrl(Dart_True()); |
| 4857 EXPECT(Dart_IsError(result)); | 4857 EXPECT(Dart_IsError(result)); |
| 4858 EXPECT_STREQ( | 4858 EXPECT_STREQ( |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4977 EXPECT_VALID(Dart_StringToCString(list_string, &list_cstr)); | 4977 EXPECT_VALID(Dart_StringToCString(list_string, &list_cstr)); |
| 4978 EXPECT_STREQ("[A2, B2, C2=, MyClass, _A2, _B2, _C2=]", list_cstr); | 4978 EXPECT_STREQ("[A2, B2, C2=, MyClass, _A2, _B2, _C2=]", list_cstr); |
| 4979 } | 4979 } |
| 4980 | 4980 |
| 4981 | 4981 |
| 4982 TEST_CASE(LibraryImportLibrary) { | 4982 TEST_CASE(LibraryImportLibrary) { |
| 4983 const char* kLibrary1Chars = | 4983 const char* kLibrary1Chars = |
| 4984 "library library1_name;"; | 4984 "library library1_name;"; |
| 4985 const char* kLibrary2Chars = | 4985 const char* kLibrary2Chars = |
| 4986 "library library2_name;"; | 4986 "library library2_name;"; |
| 4987 Dart_Handle error = Dart_Error("incoming error"); | 4987 Dart_Handle error = Dart_NewApiError("incoming error"); |
| 4988 Dart_Handle result; | 4988 Dart_Handle result; |
| 4989 | 4989 |
| 4990 Dart_Handle url = NewString("library1_url"); | 4990 Dart_Handle url = NewString("library1_url"); |
| 4991 Dart_Handle source = NewString(kLibrary1Chars); | 4991 Dart_Handle source = NewString(kLibrary1Chars); |
| 4992 Dart_Handle lib1 = Dart_LoadLibrary(url, source); | 4992 Dart_Handle lib1 = Dart_LoadLibrary(url, source); |
| 4993 EXPECT_VALID(lib1); | 4993 EXPECT_VALID(lib1); |
| 4994 | 4994 |
| 4995 url = NewString("library2_url"); | 4995 url = NewString("library2_url"); |
| 4996 source = NewString(kLibrary2Chars); | 4996 source = NewString(kLibrary2Chars); |
| 4997 Dart_Handle lib2 = Dart_LoadLibrary(url, source); | 4997 Dart_Handle lib2 = Dart_LoadLibrary(url, source); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5071 int64_t value = 0; | 5071 int64_t value = 0; |
| 5072 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); | 5072 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); |
| 5073 EXPECT_EQ(42, value); | 5073 EXPECT_EQ(42, value); |
| 5074 } | 5074 } |
| 5075 | 5075 |
| 5076 | 5076 |
| 5077 | 5077 |
| 5078 TEST_CASE(LoadLibrary) { | 5078 TEST_CASE(LoadLibrary) { |
| 5079 const char* kLibrary1Chars = | 5079 const char* kLibrary1Chars = |
| 5080 "library library1_name;"; | 5080 "library library1_name;"; |
| 5081 Dart_Handle error = Dart_Error("incoming error"); | 5081 Dart_Handle error = Dart_NewApiError("incoming error"); |
| 5082 Dart_Handle result; | 5082 Dart_Handle result; |
| 5083 | 5083 |
| 5084 Dart_Handle url = NewString("library1_url"); | 5084 Dart_Handle url = NewString("library1_url"); |
| 5085 Dart_Handle source = NewString(kLibrary1Chars); | 5085 Dart_Handle source = NewString(kLibrary1Chars); |
| 5086 | 5086 |
| 5087 result = Dart_LoadLibrary(Dart_Null(), source); | 5087 result = Dart_LoadLibrary(Dart_Null(), source); |
| 5088 EXPECT(Dart_IsError(result)); | 5088 EXPECT(Dart_IsError(result)); |
| 5089 EXPECT_STREQ("Dart_LoadLibrary expects argument 'url' to be non-null.", | 5089 EXPECT_STREQ("Dart_LoadLibrary expects argument 'url' to be non-null.", |
| 5090 Dart_GetError(result)); | 5090 Dart_GetError(result)); |
| 5091 | 5091 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5139 } | 5139 } |
| 5140 | 5140 |
| 5141 | 5141 |
| 5142 TEST_CASE(LoadSource) { | 5142 TEST_CASE(LoadSource) { |
| 5143 const char* kLibrary1Chars = | 5143 const char* kLibrary1Chars = |
| 5144 "library library1_name;"; | 5144 "library library1_name;"; |
| 5145 const char* kSourceChars = | 5145 const char* kSourceChars = |
| 5146 "part of library1_name;\n// Something innocuous"; | 5146 "part of library1_name;\n// Something innocuous"; |
| 5147 const char* kBadSourceChars = | 5147 const char* kBadSourceChars = |
| 5148 ")"; | 5148 ")"; |
| 5149 Dart_Handle error = Dart_Error("incoming error"); | 5149 Dart_Handle error = Dart_NewApiError("incoming error"); |
| 5150 Dart_Handle result; | 5150 Dart_Handle result; |
| 5151 | 5151 |
| 5152 // Load up a library. | 5152 // Load up a library. |
| 5153 Dart_Handle url = NewString("library1_url"); | 5153 Dart_Handle url = NewString("library1_url"); |
| 5154 Dart_Handle source = NewString(kLibrary1Chars); | 5154 Dart_Handle source = NewString(kLibrary1Chars); |
| 5155 Dart_Handle lib = Dart_LoadLibrary(url, source); | 5155 Dart_Handle lib = Dart_LoadLibrary(url, source); |
| 5156 EXPECT_VALID(lib); | 5156 EXPECT_VALID(lib); |
| 5157 EXPECT(Dart_IsLibrary(lib)); | 5157 EXPECT(Dart_IsLibrary(lib)); |
| 5158 | 5158 |
| 5159 url = NewString("source_url"); | 5159 url = NewString("source_url"); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5518 } | 5518 } |
| 5519 | 5519 |
| 5520 | 5520 |
| 5521 TEST_CASE(SetNativeResolver) { | 5521 TEST_CASE(SetNativeResolver) { |
| 5522 const char* kScriptChars = | 5522 const char* kScriptChars = |
| 5523 "class Test {" | 5523 "class Test {" |
| 5524 " static foo() native \"SomeNativeFunction\";" | 5524 " static foo() native \"SomeNativeFunction\";" |
| 5525 " static bar() native \"SomeNativeFunction2\";" | 5525 " static bar() native \"SomeNativeFunction2\";" |
| 5526 " static baz() native \"SomeNativeFunction3\";" | 5526 " static baz() native \"SomeNativeFunction3\";" |
| 5527 "}"; | 5527 "}"; |
| 5528 Dart_Handle error = Dart_Error("incoming error"); | 5528 Dart_Handle error = Dart_NewApiError("incoming error"); |
| 5529 Dart_Handle result; | 5529 Dart_Handle result; |
| 5530 | 5530 |
| 5531 // Load a test script. | 5531 // Load a test script. |
| 5532 Dart_Handle url = NewString(TestCase::url()); | 5532 Dart_Handle url = NewString(TestCase::url()); |
| 5533 Dart_Handle source = NewString(kScriptChars); | 5533 Dart_Handle source = NewString(kScriptChars); |
| 5534 result = Dart_SetLibraryTagHandler(library_handler); | 5534 result = Dart_SetLibraryTagHandler(library_handler); |
| 5535 EXPECT_VALID(result); | 5535 EXPECT_VALID(result); |
| 5536 Dart_Handle lib = Dart_LoadScript(url, source, 0, 0); | 5536 Dart_Handle lib = Dart_LoadScript(url, source, 0, 0); |
| 5537 EXPECT_VALID(lib); | 5537 EXPECT_VALID(lib); |
| 5538 EXPECT(Dart_IsLibrary(lib)); | 5538 EXPECT(Dart_IsLibrary(lib)); |
| (...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7360 NewString("main"), | 7360 NewString("main"), |
| 7361 0, | 7361 0, |
| 7362 NULL); | 7362 NULL); |
| 7363 int64_t value = 0; | 7363 int64_t value = 0; |
| 7364 result = Dart_IntegerToInt64(result, &value); | 7364 result = Dart_IntegerToInt64(result, &value); |
| 7365 EXPECT_VALID(result); | 7365 EXPECT_VALID(result); |
| 7366 EXPECT_EQ(8, value); | 7366 EXPECT_EQ(8, value); |
| 7367 } | 7367 } |
| 7368 | 7368 |
| 7369 } // namespace dart | 7369 } // namespace dart |
| OLD | NEW |