Chromium Code Reviews| 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 8195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8206 Dart_Handle result = Dart_Invoke(lib, | 8206 Dart_Handle result = Dart_Invoke(lib, |
| 8207 NewString("main"), | 8207 NewString("main"), |
| 8208 0, | 8208 0, |
| 8209 NULL); | 8209 NULL); |
| 8210 int64_t value = 0; | 8210 int64_t value = 0; |
| 8211 result = Dart_IntegerToInt64(result, &value); | 8211 result = Dart_IntegerToInt64(result, &value); |
| 8212 EXPECT_VALID(result); | 8212 EXPECT_VALID(result); |
| 8213 EXPECT_EQ(8, value); | 8213 EXPECT_EQ(8, value); |
| 8214 } | 8214 } |
| 8215 | 8215 |
| 8216 | |
| 8217 TEST_CASE(AmbiguousReference) { | |
| 8218 const char* kImportedScript1Chars = | |
| 8219 "library library1.dart;\n" | |
| 8220 "var foo;\n" | |
| 8221 "bar() => 'library1.dart bar()';\n" | |
| 8222 "baz() => 'library1.dart baz()';\n" | |
| 8223 "var bay;\n" | |
| 8224 "typedef int bax(int a, int b);\n" | |
| 8225 "class baw {}\n"; | |
| 8226 const char* kImportedScript2Chars = | |
| 8227 "library library2.dart;\n" | |
| 8228 "var foo;\n" | |
| 8229 "bar() => 'library2.dart bar()';\n" | |
| 8230 "var baz;\n" | |
| 8231 "bay() => 'library2.dart bay()';\n" | |
| 8232 "typedef double bax(int a, int b);\n" | |
| 8233 "var baw;\n"; | |
| 8234 const char* kScriptChars = | |
| 8235 "import 'library1.dart';\n" | |
| 8236 "import 'library2.dart';\n"; | |
| 8237 | |
| 8238 // Load imported libs. | |
| 8239 Dart_Handle url1 = NewString("library1.dart"); | |
| 8240 Dart_Handle source1 = NewString(kImportedScript1Chars); | |
| 8241 Dart_Handle imported_lib1 = Dart_LoadLibrary(url1, source1); | |
| 8242 EXPECT_VALID(imported_lib1); | |
| 8243 Dart_Handle url2 = NewString("library2.dart"); | |
| 8244 Dart_Handle source2 = NewString(kImportedScript2Chars); | |
| 8245 Dart_Handle imported_lib2 = Dart_LoadLibrary(url2, source2); | |
| 8246 EXPECT_VALID(imported_lib2); | |
| 8247 // Load main script. | |
| 8248 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | |
| 8249 EXPECT_VALID(lib); | |
| 8250 Dart_Handle prefix = NewString(""); | |
| 8251 Dart_Handle result; | |
| 8252 result = Dart_LibraryImportLibrary(lib, imported_lib1, prefix); | |
| 8253 EXPECT_VALID(result); | |
| 8254 result = Dart_LibraryImportLibrary(lib, imported_lib2, prefix); | |
| 8255 EXPECT_VALID(result); | |
| 8256 EXPECT(Dart_IsError(Dart_LookupVariable(lib, NewString("foo")))); | |
| 8257 EXPECT(Dart_IsError(Dart_LookupFunction(lib, NewString("bar")))); | |
| 8258 EXPECT(Dart_IsError(Dart_LookupFunction(lib, NewString("baz")))); | |
| 8259 EXPECT(Dart_IsError(Dart_LookupVariable(lib, NewString("bay")))); | |
| 8260 EXPECT(Dart_IsError(Dart_GetClass(lib, NewString("bax")))); | |
| 8261 EXPECT(Dart_IsError(Dart_GetClass(lib, NewString("baw")))); | |
|
siva
2013/07/22 22:21:46
Would be good to have a positive test here too.
Sa
regis
2013/07/22 23:51:27
Done.
| |
| 8262 } | |
| 8263 | |
| 8216 } // namespace dart | 8264 } // namespace dart |
| OLD | NEW |