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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 19662003: Refactor resolution code in the vm to properly handle ambiguity errors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/dart_api_impl_test.cc
===================================================================
--- runtime/vm/dart_api_impl_test.cc (revision 25291)
+++ runtime/vm/dart_api_impl_test.cc (working copy)
@@ -8213,4 +8213,52 @@
EXPECT_EQ(8, value);
}
+
+TEST_CASE(AmbiguousReference) {
+ const char* kImportedScript1Chars =
+ "library library1.dart;\n"
+ "var foo;\n"
+ "bar() => 'library1.dart bar()';\n"
+ "baz() => 'library1.dart baz()';\n"
+ "var bay;\n"
+ "typedef int bax(int a, int b);\n"
+ "class baw {}\n";
+ const char* kImportedScript2Chars =
+ "library library2.dart;\n"
+ "var foo;\n"
+ "bar() => 'library2.dart bar()';\n"
+ "var baz;\n"
+ "bay() => 'library2.dart bay()';\n"
+ "typedef double bax(int a, int b);\n"
+ "var baw;\n";
+ const char* kScriptChars =
+ "import 'library1.dart';\n"
+ "import 'library2.dart';\n";
+
+ // Load imported libs.
+ Dart_Handle url1 = NewString("library1.dart");
+ Dart_Handle source1 = NewString(kImportedScript1Chars);
+ Dart_Handle imported_lib1 = Dart_LoadLibrary(url1, source1);
+ EXPECT_VALID(imported_lib1);
+ Dart_Handle url2 = NewString("library2.dart");
+ Dart_Handle source2 = NewString(kImportedScript2Chars);
+ Dart_Handle imported_lib2 = Dart_LoadLibrary(url2, source2);
+ EXPECT_VALID(imported_lib2);
+ // Load main script.
+ Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
+ EXPECT_VALID(lib);
+ Dart_Handle prefix = NewString("");
+ Dart_Handle result;
+ result = Dart_LibraryImportLibrary(lib, imported_lib1, prefix);
+ EXPECT_VALID(result);
+ result = Dart_LibraryImportLibrary(lib, imported_lib2, prefix);
+ EXPECT_VALID(result);
+ EXPECT(Dart_IsError(Dart_LookupVariable(lib, NewString("foo"))));
+ EXPECT(Dart_IsError(Dart_LookupFunction(lib, NewString("bar"))));
+ EXPECT(Dart_IsError(Dart_LookupFunction(lib, NewString("baz"))));
+ EXPECT(Dart_IsError(Dart_LookupVariable(lib, NewString("bay"))));
+ EXPECT(Dart_IsError(Dart_GetClass(lib, NewString("bax"))));
+ 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.
+}
+
} // namespace dart

Powered by Google App Engine
This is Rietveld 408576698