Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Side by Side Diff: runtime/vm/dart_api_impl_test.cc

Issue 8528018: Start checking inputs to dart api functions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 6
7 #include "vm/assert.h" 7 #include "vm/assert.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/dart_api_state.h" 9 #include "vm/dart_api_state.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 1771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 static Dart_Handle library_handler(Dart_LibraryTag tag, 1782 static Dart_Handle library_handler(Dart_LibraryTag tag,
1783 Dart_Handle library, 1783 Dart_Handle library,
1784 Dart_Handle url) { 1784 Dart_Handle url) {
1785 if (tag == kCanonicalizeUrl) { 1785 if (tag == kCanonicalizeUrl) {
1786 return url; 1786 return url;
1787 } 1787 }
1788 return Api::Success(); 1788 return Api::Success();
1789 } 1789 }
1790 1790
1791 1791
1792 UNIT_TEST_CASE(LoadScript) {
1793 const char* kScriptChars =
1794 "main() {"
1795 " return 12345;"
1796 "}";
1797
1798 Dart_CreateIsolate(NULL, NULL);
1799 Dart_EnterScope();
1800
1801 Dart_Handle url = Dart_NewString(TestCase::url());
1802 Dart_Handle source = Dart_NewString(kScriptChars);
1803 Dart_Handle error = Dart_Error("incoming error");
1804 Dart_Handle result;
1805
1806 result = Dart_LoadScript(Dart_Null(), source, library_handler);
1807 EXPECT(!Dart_IsValid(result));
siva 2011/11/15 22:09:49 I guess in the new API style this would be EXPECT(
turnidge 2011/11/15 23:30:42 Yes. Synced and resolved.
1808 EXPECT_STREQ("Dart_LoadScript expects argument 'url' to be non-null.",
1809 Dart_GetError(result));
1810
1811 result = Dart_LoadScript(Dart_True(), source, library_handler);
1812 EXPECT(!Dart_IsValid(result));
1813 EXPECT_STREQ("Dart_LoadScript expects argument 'url' to be of type String.",
1814 Dart_GetError(result));
1815
1816 result = Dart_LoadScript(error, source, library_handler);
1817 EXPECT(!Dart_IsValid(result));
1818 EXPECT_STREQ("incoming error", Dart_GetError(result));
1819
1820 result = Dart_LoadScript(url, Dart_Null(), library_handler);
1821 EXPECT(!Dart_IsValid(result));
1822 EXPECT_STREQ("Dart_LoadScript expects argument 'source' to be non-null.",
1823 Dart_GetError(result));
1824
1825 result = Dart_LoadScript(url, Dart_True(), library_handler);
1826 EXPECT(!Dart_IsValid(result));
1827 EXPECT_STREQ(
1828 "Dart_LoadScript expects argument 'source' to be of type String.",
1829 Dart_GetError(result));
1830
1831 result = Dart_LoadScript(url, error, library_handler);
1832 EXPECT(!Dart_IsValid(result));
1833 EXPECT_STREQ("incoming error", Dart_GetError(result));
1834
1835 // Load a script successfully.
1836 result = Dart_LoadScript(url, source, library_handler);
1837 EXPECT_VALID(result);
1838
1839 result = Dart_InvokeStatic(result,
1840 Dart_NewString(""),
1841 Dart_NewString("main"),
1842 0,
1843 NULL);
1844 EXPECT_VALID(result);
1845 EXPECT(Dart_IsInteger(result));
1846 int64_t value = 0;
1847 EXPECT_VALID(Dart_IntegerValue(result, &value));
1848 EXPECT_EQ(12345, value);
1849
1850 // Further calls to LoadScript are errors.
1851 result = Dart_LoadScript(url, source, library_handler);
1852 EXPECT(!Dart_IsValid(result));
1853 EXPECT_STREQ("Dart_LoadScript: "
1854 "A script has already been loaded from 'dart:test-lib'.",
1855 Dart_GetError(result));
1856
1857 Dart_ExitScope();
1858 Dart_ShutdownIsolate();
1859 }
1860
1861
1862 UNIT_TEST_CASE(LoadScript_CompileError) {
1863 const char* kScriptChars =
1864 ")";
1865
1866 Dart_CreateIsolate(NULL, NULL);
1867 Dart_EnterScope();
1868
1869 Dart_Handle url = Dart_NewString(TestCase::url());
1870 Dart_Handle source = Dart_NewString(kScriptChars);
1871 Dart_Handle result = Dart_LoadScript(url, source, library_handler);
1872 EXPECT(!Dart_IsValid(result));
1873 EXPECT(strstr(Dart_GetError(result), "unexpected token ')'"));
1874
1875 Dart_ExitScope();
1876 Dart_ShutdownIsolate();
1877 }
1878
1879
1792 UNIT_TEST_CASE(LookupLibrary) { 1880 UNIT_TEST_CASE(LookupLibrary) {
1793 const char* kScriptChars = 1881 const char* kScriptChars =
1794 "#import('library1.dart');" 1882 "#import('library1.dart');"
1795 "main() {}"; 1883 "main() {}";
1796 const char* kLibrary1Chars = 1884 const char* kLibrary1Chars =
1797 "#library('library1.dart');" 1885 "#library('library1.dart');"
1798 "#import('library2.dart');"; 1886 "#import('library2.dart');";
1799 1887
1800 Dart_CreateIsolate(NULL, NULL); 1888 Dart_CreateIsolate(NULL, NULL);
1801 Dart_EnterScope(); 1889 Dart_EnterScope();
(...skipping 16 matching lines...) Expand all
1818 EXPECT(!Dart_IsValid(result)); 1906 EXPECT(!Dart_IsValid(result));
1819 EXPECT_STREQ("Dart_LookupLibrary expects argument 'url' to be non-null.", 1907 EXPECT_STREQ("Dart_LookupLibrary expects argument 'url' to be non-null.",
1820 Dart_GetError(result)); 1908 Dart_GetError(result));
1821 1909
1822 result = Dart_LookupLibrary(Dart_True()); 1910 result = Dart_LookupLibrary(Dart_True());
1823 EXPECT(!Dart_IsValid(result)); 1911 EXPECT(!Dart_IsValid(result));
1824 EXPECT_STREQ( 1912 EXPECT_STREQ(
1825 "Dart_LookupLibrary expects argument 'url' to be of type String.", 1913 "Dart_LookupLibrary expects argument 'url' to be of type String.",
1826 Dart_GetError(result)); 1914 Dart_GetError(result));
1827 1915
1828 result = Dart_LookupLibrary(Dart_Error("incoming error pass-thru")); 1916 result = Dart_LookupLibrary(Dart_Error("incoming error"));
1829 EXPECT(!Dart_IsValid(result)); 1917 EXPECT(!Dart_IsValid(result));
1830 EXPECT_STREQ("incoming error pass-thru", Dart_GetError(result)); 1918 EXPECT_STREQ("incoming error", Dart_GetError(result));
1831 1919
1832 url = Dart_NewString("noodles.dart"); 1920 url = Dart_NewString("noodles.dart");
1833 result = Dart_LookupLibrary(url); 1921 result = Dart_LookupLibrary(url);
1834 EXPECT(!Dart_IsValid(result)); 1922 EXPECT(!Dart_IsValid(result));
1835 EXPECT_STREQ("Dart_LookupLibrary: library 'noodles.dart' not found.", 1923 EXPECT_STREQ("Dart_LookupLibrary: library 'noodles.dart' not found.",
1836 Dart_GetError(result)); 1924 Dart_GetError(result));
1837 1925
1838 Dart_ExitScope(); 1926 Dart_ExitScope();
1839 Dart_ShutdownIsolate(); 1927 Dart_ShutdownIsolate();
1840 } 1928 }
1841 1929
1842 1930
1931 UNIT_TEST_CASE(LibraryUrl) {
1932 const char* kLibrary1Chars =
1933 "#library('library1_name');";
1934
1935 Dart_CreateIsolate(NULL, NULL);
1936 Dart_EnterScope();
1937
1938 Dart_Handle url = Dart_NewString("library1_url");
1939 Dart_Handle source = Dart_NewString(kLibrary1Chars);
1940 Dart_Handle lib = Dart_LoadLibrary(url, source);
1941 Dart_Handle error = Dart_Error("incoming error");
1942 EXPECT_VALID(lib);
1943
1944 Dart_Handle result = Dart_LibraryUrl(Dart_Null());
1945 EXPECT(!Dart_IsValid(result));
1946 EXPECT_STREQ("Dart_LibraryUrl expects argument 'library' to be non-null.",
1947 Dart_GetError(result));
1948
1949 result = Dart_LibraryUrl(Dart_True());
1950 EXPECT(!Dart_IsValid(result));
1951 EXPECT_STREQ(
1952 "Dart_LibraryUrl expects argument 'library' to be of type Library.",
1953 Dart_GetError(result));
1954
1955 result = Dart_LibraryUrl(error);
1956 EXPECT(!Dart_IsValid(result));
1957 EXPECT_STREQ("incoming error", Dart_GetError(result));
1958
1959 result = Dart_LibraryUrl(lib);
1960 EXPECT_VALID(result);
1961 EXPECT(Dart_IsString(result));
1962 const char* cstr = NULL;
1963 EXPECT_VALID(Dart_StringToCString(result, &cstr));
1964 EXPECT_STREQ("library1_url", cstr);
1965
1966 Dart_ExitScope();
1967 Dart_ShutdownIsolate();
1968 }
1969
1970
1971 UNIT_TEST_CASE(LibraryImportLibrary) {
1972 const char* kLibrary1Chars =
1973 "#library('library1_name');";
1974 const char* kLibrary2Chars =
1975 "#library('library2_name');";
1976
1977 Dart_CreateIsolate(NULL, NULL);
1978 Dart_EnterScope();
1979
1980 Dart_Handle error = Dart_Error("incoming error");
1981 Dart_Handle result;
1982
1983 Dart_Handle url = Dart_NewString("library1_url");
1984 Dart_Handle source = Dart_NewString(kLibrary1Chars);
1985 Dart_Handle lib1 = Dart_LoadLibrary(url, source);
1986 EXPECT_VALID(lib1);
1987
1988 url = Dart_NewString("library2_url");
1989 source = Dart_NewString(kLibrary2Chars);
1990 Dart_Handle lib2 = Dart_LoadLibrary(url, source);
1991 EXPECT_VALID(lib2);
1992
1993 result = Dart_LibraryImportLibrary(Dart_Null(), lib2);
1994 EXPECT(!Dart_IsValid(result));
1995 EXPECT_STREQ(
1996 "Dart_LibraryImportLibrary expects argument 'library' to be non-null.",
1997 Dart_GetError(result));
1998
1999 result = Dart_LibraryImportLibrary(Dart_True(), lib2);
2000 EXPECT(!Dart_IsValid(result));
2001 EXPECT_STREQ("Dart_LibraryImportLibrary expects argument 'library' to be of "
2002 "type Library.",
2003 Dart_GetError(result));
2004
2005 result = Dart_LibraryImportLibrary(error, lib2);
2006 EXPECT(!Dart_IsValid(result));
2007 EXPECT_STREQ("incoming error", Dart_GetError(result));
2008
2009 result = Dart_LibraryImportLibrary(lib1, Dart_Null());
2010 EXPECT(!Dart_IsValid(result));
2011 EXPECT_STREQ(
2012 "Dart_LibraryImportLibrary expects argument 'import' to be non-null.",
2013 Dart_GetError(result));
2014
2015 result = Dart_LibraryImportLibrary(lib1, Dart_True());
2016 EXPECT(!Dart_IsValid(result));
2017 EXPECT_STREQ("Dart_LibraryImportLibrary expects argument 'import' to be of "
2018 "type Library.",
2019 Dart_GetError(result));
2020
2021 result = Dart_LibraryImportLibrary(lib1, error);
2022 EXPECT(!Dart_IsValid(result));
2023 EXPECT_STREQ("incoming error", Dart_GetError(result));
2024
2025 result = Dart_LibraryImportLibrary(lib1, lib2);
2026 EXPECT_VALID(result);
2027
2028 Dart_ExitScope();
2029 Dart_ShutdownIsolate();
2030 }
2031
2032
2033
2034 UNIT_TEST_CASE(LoadLibrary) {
2035 const char* kLibrary1Chars =
2036 "#library('library1_name');";
2037
2038 Dart_CreateIsolate(NULL, NULL);
2039 Dart_EnterScope();
2040
2041 Dart_Handle error = Dart_Error("incoming error");
2042 Dart_Handle result;
2043
2044 Dart_Handle url = Dart_NewString("library1_url");
2045 Dart_Handle source = Dart_NewString(kLibrary1Chars);
2046
2047 result = Dart_LoadLibrary(Dart_Null(), source);
2048 EXPECT(!Dart_IsValid(result));
2049 EXPECT_STREQ("Dart_LoadLibrary expects argument 'url' to be non-null.",
2050 Dart_GetError(result));
2051
2052 result = Dart_LoadLibrary(Dart_True(), source);
2053 EXPECT(!Dart_IsValid(result));
2054 EXPECT_STREQ("Dart_LoadLibrary expects argument 'url' to be of type String.",
2055 Dart_GetError(result));
2056
2057 result = Dart_LoadLibrary(error, source);
2058 EXPECT(!Dart_IsValid(result));
2059 EXPECT_STREQ("incoming error", Dart_GetError(result));
2060
2061 result = Dart_LoadLibrary(url, Dart_Null());
2062 EXPECT(!Dart_IsValid(result));
2063 EXPECT_STREQ("Dart_LoadLibrary expects argument 'source' to be non-null.",
2064 Dart_GetError(result));
2065
2066 result = Dart_LoadLibrary(url, Dart_True());
2067 EXPECT(!Dart_IsValid(result));
2068 EXPECT_STREQ(
2069 "Dart_LoadLibrary expects argument 'source' to be of type String.",
2070 Dart_GetError(result));
2071
2072 result = Dart_LoadLibrary(url, error);
2073 EXPECT(!Dart_IsValid(result));
2074 EXPECT_STREQ("incoming error", Dart_GetError(result));
2075
2076 // Success.
2077 result = Dart_LoadLibrary(url, source);
2078 EXPECT_VALID(result);
2079 EXPECT(Dart_IsLibrary(result));
2080
2081 // Duplicate library load fails.
2082 result = Dart_LoadLibrary(url, source);
2083 EXPECT(!Dart_IsValid(result));
2084 EXPECT_STREQ(
2085 "Dart_LoadLibrary: library 'library1_url' has already been loaded.",
2086 Dart_GetError(result));
2087
2088 Dart_ExitScope();
2089 Dart_ShutdownIsolate();
2090 }
2091
2092
2093 UNIT_TEST_CASE(LoadLibrary_CompileError) {
2094 const char* kLibrary1Chars =
2095 "#library('library1_name');"
2096 ")";
2097
2098 Dart_CreateIsolate(NULL, NULL);
2099 Dart_EnterScope();
2100
2101 Dart_Handle url = Dart_NewString("library1_url");
2102 Dart_Handle source = Dart_NewString(kLibrary1Chars);
2103 Dart_Handle result = Dart_LoadLibrary(url, source);
2104 EXPECT(!Dart_IsValid(result));
2105 EXPECT(strstr(Dart_GetError(result), "unexpected token ')'"));
2106
2107 Dart_ExitScope();
2108 Dart_ShutdownIsolate();
2109 }
2110
2111
2112 UNIT_TEST_CASE(LoadSource) {
2113 const char* kLibrary1Chars =
2114 "#library('library1_name');";
2115 const char* kSourceChars =
2116 "// Something innocuous";
2117 const char* kBadSourceChars =
2118 ")";
2119
2120 Dart_CreateIsolate(NULL, NULL);
2121 Dart_EnterScope();
2122
2123 Dart_Handle error = Dart_Error("incoming error");
2124 Dart_Handle result;
2125
2126 // Load up a library.
2127 Dart_Handle url = Dart_NewString("library1_url");
2128 Dart_Handle source = Dart_NewString(kLibrary1Chars);
2129 Dart_Handle lib = Dart_LoadLibrary(url, source);
2130 EXPECT_VALID(lib);
2131 EXPECT(Dart_IsLibrary(lib));
2132
2133 url = Dart_NewString("source_url");
2134 source = Dart_NewString(kSourceChars);
2135
2136 result = Dart_LoadSource(Dart_Null(), url, source);
2137 EXPECT(!Dart_IsValid(result));
2138 EXPECT_STREQ("Dart_LoadSource expects argument 'library' to be non-null.",
2139 Dart_GetError(result));
2140
2141 result = Dart_LoadSource(Dart_True(), url, source);
2142 EXPECT(!Dart_IsValid(result));
2143 EXPECT_STREQ(
2144 "Dart_LoadSource expects argument 'library' to be of type Library.",
2145 Dart_GetError(result));
2146
2147 result = Dart_LoadSource(error, url, source);
2148 EXPECT(!Dart_IsValid(result));
2149 EXPECT_STREQ("incoming error", Dart_GetError(result));
2150
2151 result = Dart_LoadSource(lib, Dart_Null(), source);
2152 EXPECT(!Dart_IsValid(result));
2153 EXPECT_STREQ("Dart_LoadSource expects argument 'url' to be non-null.",
2154 Dart_GetError(result));
2155
2156 result = Dart_LoadSource(lib, Dart_True(), source);
2157 EXPECT(!Dart_IsValid(result));
2158 EXPECT_STREQ("Dart_LoadSource expects argument 'url' to be of type String.",
2159 Dart_GetError(result));
2160
2161 result = Dart_LoadSource(lib, error, source);
2162 EXPECT(!Dart_IsValid(result));
2163 EXPECT_STREQ("incoming error", Dart_GetError(result));
2164
2165 result = Dart_LoadSource(lib, url, Dart_Null());
2166 EXPECT(!Dart_IsValid(result));
2167 EXPECT_STREQ("Dart_LoadSource expects argument 'source' to be non-null.",
2168 Dart_GetError(result));
2169
2170 result = Dart_LoadSource(lib, url, Dart_True());
2171 EXPECT(!Dart_IsValid(result));
2172 EXPECT_STREQ(
2173 "Dart_LoadSource expects argument 'source' to be of type String.",
2174 Dart_GetError(result));
2175
2176 result = Dart_LoadSource(lib, error, source);
2177 EXPECT(!Dart_IsValid(result));
2178 EXPECT_STREQ("incoming error", Dart_GetError(result));
2179
2180 // Success.
2181 result = Dart_LoadSource(lib, url, source);
2182 EXPECT_VALID(result);
2183 EXPECT(Dart_IsLibrary(result));
2184 bool same = false;
2185 EXPECT_VALID(Dart_IsSame(lib, result, &same));
2186 EXPECT(same);
2187
2188 // Duplicate calls are okay.
2189 result = Dart_LoadSource(lib, url, source);
2190 EXPECT_VALID(result);
2191 EXPECT(Dart_IsLibrary(result));
2192 same = false;
2193 EXPECT_VALID(Dart_IsSame(lib, result, &same));
2194 EXPECT(same);
2195
2196 // Language errors are detected.
2197 source = Dart_NewString(kBadSourceChars);
2198 result = Dart_LoadSource(lib, url, source);
2199 EXPECT(!Dart_IsValid(result));
2200
2201 Dart_ExitScope();
2202 Dart_ShutdownIsolate();
2203 }
2204
2205
2206 static void MyNativeFunction1(Dart_NativeArguments args) {
2207 Dart_EnterScope();
2208 Dart_SetReturnValue(args, Dart_NewInteger(654321));
2209 Dart_ExitScope();
2210 }
2211
2212
2213 static void MyNativeFunction2(Dart_NativeArguments args) {
2214 Dart_EnterScope();
2215 Dart_SetReturnValue(args, Dart_NewInteger(123456));
2216 Dart_ExitScope();
2217 }
2218
2219
2220 static Dart_NativeFunction MyNativeResolver1(Dart_Handle name,
2221 int arg_count) {
2222 return &MyNativeFunction1;
2223 }
2224
2225
2226 static Dart_NativeFunction MyNativeResolver2(Dart_Handle name,
2227 int arg_count) {
2228 return &MyNativeFunction2;
2229 }
2230
2231
2232 UNIT_TEST_CASE(SetNativeResolver) {
2233 const char* kScriptChars =
2234 "class Test {"
2235 " static foo() native \"SomeNativeFunction\";"
2236 " static bar() native \"SomeNativeFunction2\";"
2237 " static baz() native \"SomeNativeFunction3\";"
2238 "}";
2239
2240 Dart_CreateIsolate(NULL, NULL);
2241 Dart_EnterScope();
2242
2243 Dart_Handle error = Dart_Error("incoming error");
2244 Dart_Handle result;
2245
2246 // Load a test script.
2247 Dart_Handle url = Dart_NewString(TestCase::url());
2248 Dart_Handle source = Dart_NewString(kScriptChars);
2249 Dart_Handle lib = Dart_LoadScript(url, source, library_handler);
2250 EXPECT_VALID(lib);
2251 EXPECT(Dart_IsLibrary(lib));
2252
2253 result = Dart_SetNativeResolver(Dart_Null(), &MyNativeResolver1);
2254 EXPECT(!Dart_IsValid(result));
2255 EXPECT_STREQ(
2256 "Dart_SetNativeResolver expects argument 'library' to be non-null.",
2257 Dart_GetError(result));
2258
2259 result = Dart_SetNativeResolver(Dart_True(), &MyNativeResolver1);
2260 EXPECT(!Dart_IsValid(result));
2261 EXPECT_STREQ("Dart_SetNativeResolver expects argument 'library' to be of "
2262 "type Library.",
2263 Dart_GetError(result));
2264
2265 result = Dart_SetNativeResolver(error, &MyNativeResolver1);
2266 EXPECT(!Dart_IsValid(result));
2267 EXPECT_STREQ("incoming error", Dart_GetError(result));
2268
2269 result = Dart_SetNativeResolver(lib, &MyNativeResolver1);
2270 EXPECT_VALID(result);
2271
2272 // Call a function and make sure native resolution works.
2273 result = Dart_InvokeStatic(lib,
2274 Dart_NewString("Test"),
2275 Dart_NewString("foo"),
2276 0,
2277 NULL);
2278 EXPECT_VALID(result);
2279 EXPECT(Dart_IsInteger(result));
2280 int64_t value = 0;
2281 EXPECT_VALID(Dart_IntegerValue(result, &value));
2282 EXPECT_EQ(654321, value);
2283
2284 // A second call succeeds.
2285 result = Dart_SetNativeResolver(lib, &MyNativeResolver2);
2286 EXPECT_VALID(result);
2287
2288 // 'foo' has already been resolved so gets the old value.
2289 result = Dart_InvokeStatic(lib,
2290 Dart_NewString("Test"),
2291 Dart_NewString("foo"),
2292 0,
2293 NULL);
2294 EXPECT_VALID(result);
2295 EXPECT(Dart_IsInteger(result));
2296 value = 0;
2297 EXPECT_VALID(Dart_IntegerValue(result, &value));
2298 EXPECT_EQ(654321, value);
2299
2300 // 'bar' has not yet been resolved so gets the new value.
2301 result = Dart_InvokeStatic(lib,
2302 Dart_NewString("Test"),
2303 Dart_NewString("bar"),
2304 0,
2305 NULL);
2306 EXPECT_VALID(result);
2307 EXPECT(Dart_IsInteger(result));
2308 value = 0;
2309 EXPECT_VALID(Dart_IntegerValue(result, &value));
2310 EXPECT_EQ(123456, value);
2311
2312 // A NULL resolver is okay, but resolution will fail.
2313 result = Dart_SetNativeResolver(lib, NULL);
2314 EXPECT_VALID(result);
2315
2316 result = Dart_InvokeStatic(lib,
2317 Dart_NewString("Test"),
2318 Dart_NewString("baz"),
2319 0,
2320 NULL);
2321 EXPECT(!Dart_IsValid(result));
2322 EXPECT(strstr(Dart_GetError(result),
2323 "native function 'SomeNativeFunction3' cannot be found"));
2324
2325 Dart_ExitScope();
2326 Dart_ShutdownIsolate();
2327 }
2328
2329
1843 UNIT_TEST_CASE(ImportLibrary1) { 2330 UNIT_TEST_CASE(ImportLibrary1) {
1844 const char* kScriptChars = 2331 const char* kScriptChars =
1845 "#import('library1.dart');" 2332 "#import('library1.dart');"
1846 "#import('library2.dart');" 2333 "#import('library2.dart');"
1847 "var foo; // library2 defines foo, so should be error." 2334 "var foo; // library2 defines foo, so should be error."
1848 "main() {}"; 2335 "main() {}";
1849 const char* kLibrary1Chars = 2336 const char* kLibrary1Chars =
1850 "#library('library1.dart');" 2337 "#library('library1.dart');"
1851 "#import('library2.dart');" 2338 "#import('library2.dart');"
1852 "var foo1;"; 2339 "var foo1;";
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
2096 NULL); 2583 NULL);
2097 EXPECT_VALID(result); 2584 EXPECT_VALID(result);
2098 2585
2099 Dart_ExitScope(); // Exit the Dart API scope. 2586 Dart_ExitScope(); // Exit the Dart API scope.
2100 } 2587 }
2101 Dart_ShutdownIsolate(); 2588 Dart_ShutdownIsolate();
2102 } 2589 }
2103 #endif // TARGET_ARCH_IA32. 2590 #endif // TARGET_ARCH_IA32.
2104 2591
2105 } // namespace dart 2592 } // namespace dart
OLDNEW
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698