@@ -110,7 +110,7 @@ TEST_F(CoreAPIsStandardTest, MaterializationSideEffctsOnlyBasic) {
110
110
111
111
ES.lookup (
112
112
LookupKind::Static, makeJITDylibSearchOrder (&JD),
113
- SymbolLookupSet ({ Foo} , SymbolLookupFlags::WeaklyReferencedSymbol),
113
+ SymbolLookupSet (Foo, SymbolLookupFlags::WeaklyReferencedSymbol),
114
114
SymbolState::Ready,
115
115
[&](Expected<SymbolMap> LookupResult) {
116
116
if (LookupResult)
@@ -1088,6 +1088,53 @@ TEST_F(CoreAPIsStandardTest, GeneratorTest) {
1088
1088
<< " Expected fallback def for Bar to be equal to BarSym" ;
1089
1089
}
1090
1090
1091
+ TEST_F (CoreAPIsStandardTest, AsynchronousGeneratorTest) {
1092
+ class TestGenerator : public DefinitionGenerator {
1093
+ public:
1094
+ TestGenerator (LookupState &TLS) : TLS(TLS) {}
1095
+ Error tryToGenerate (LookupState &LS, LookupKind K, JITDylib &JD,
1096
+ JITDylibLookupFlags JDLookupFlags,
1097
+ const SymbolLookupSet &Name) override {
1098
+ TLS = std::move (LS);
1099
+ return Error::success ();
1100
+ }
1101
+
1102
+ private:
1103
+ LookupState &TLS;
1104
+ };
1105
+
1106
+ LookupState LS;
1107
+ JD.addGenerator (std::make_unique<TestGenerator>(LS));
1108
+
1109
+ bool LookupCompleted = false ;
1110
+
1111
+ ES.lookup (
1112
+ LookupKind::Static, makeJITDylibSearchOrder (&JD), SymbolLookupSet (Foo),
1113
+ SymbolState::Ready,
1114
+ [&](Expected<SymbolMap> Result) {
1115
+ LookupCompleted = true ;
1116
+ if (!Result) {
1117
+ ADD_FAILURE () << " Lookup failed unexpected" ;
1118
+ logAllUnhandledErrors (Result.takeError (), errs (), " " );
1119
+ return ;
1120
+ }
1121
+
1122
+ EXPECT_EQ (Result->size (), 1U ) << " Unexpected number of results" ;
1123
+ EXPECT_EQ (Result->count (Foo), 1U ) << " Expected result for Foo" ;
1124
+ EXPECT_EQ ((*Result)[Foo].getAddress (), FooSym.getAddress ())
1125
+ << " Bad result for Foo" ;
1126
+ },
1127
+ NoDependenciesToRegister);
1128
+
1129
+ EXPECT_FALSE (LookupCompleted);
1130
+
1131
+ cantFail (JD.define (absoluteSymbols ({{Foo, FooSym}})));
1132
+
1133
+ LS.continueLookup (Error::success ());
1134
+
1135
+ EXPECT_TRUE (LookupCompleted);
1136
+ }
1137
+
1091
1138
TEST_F (CoreAPIsStandardTest, FailResolution) {
1092
1139
auto MU = std::make_unique<SimpleMaterializationUnit>(
1093
1140
SymbolFlagsMap ({{Foo, JITSymbolFlags::Exported | JITSymbolFlags::Weak},
0 commit comments