@@ -7,6 +7,7 @@ are only available as binary (e.g., as.tpl files on the libs path).
77module lang ::rascalcore ::check ::tests ::BinaryDependencyTests
88
99import lang ::rascalcore ::check ::Checker ;
10+ import lang ::rascalcore ::check ::TestConfigs ;
1011import util ::Reflective ;
1112import IO ;
1213import lang ::rascalcore ::check ::Import ;
@@ -146,8 +147,46 @@ bool checkExpectErrors(str mname, list[str] expected, PathConfig pcfg, list[Proj
146147
147148TModel check (str mname , RascalCompilerConfig cfg ){
148149 ModuleStatus ms = rascalTModelForNames ([mname ], cfg , dummy_compile1 );
149- tmodels = ms .tmodels ;
150- return ms .tmodels [mname ];
150+ <found , tm , ms > = getTModelForModule (mname , ms );
151+ if (found ) return tm ;
152+ throw "check: no TModel found for <mname > " ;
153+ }
154+
155+ // --- Tests for source libraries --------------------------------------------
156+
157+ test bool importSimpleSourceModuleWithRascalAsLib (){
158+ libName = "test-lib" ;
159+ lib =
160+ createProject (
161+ libName ,
162+ ("Lib" : "int fib(int n) {
163+ ' if (n \< 2) {
164+ ' return 1;
165+ ' }
166+ ' return fib(n - 1) + fib(n -2);
167+ '}" ),
168+ createPathConfig (libName )
169+ );
170+
171+ assert checkExpectNoErrors ("Lib" , lib .pcfg );
172+
173+ rascalPCFG = getRascalPathConfig ();
174+ clientName = "test-project" ;
175+ client =
176+ createProject (
177+ clientName ,
178+ ("LibCall" : "import Lib;
179+ 'import IO;
180+ '
181+ 'int main() {
182+ ' println(fib(4));
183+ ' return 0;
184+ '}" ),
185+ createPathConfig (clientName )
186+ [libs =[rascalPCFG .resources ]]
187+ [srcs =[src (clientName ), src (libName )]]
188+ );
189+ return checkExpectNoErrors ("LibCall" , client .pcfg , remove = [lib , client ]);
151190}
152191
153192// ---- Tests for binary libraries --------------------------------------------
0 commit comments