Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit e259409

Browse files
committed
Added test inspired by refactoring work by @toinehartman
1 parent 915f937 commit e259409

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

src/org/rascalmpl/core/library/lang/rascalcore/check/tests/BinaryDependencyTests.rsc

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ are only available as binary (e.g., as.tpl files on the libs path).
77
module lang::rascalcore::check::tests::BinaryDependencyTests
88

99
import lang::rascalcore::check::Checker;
10+
import lang::rascalcore::check::TestConfigs;
1011
import util::Reflective;
1112
import IO;
1213
import lang::rascalcore::check::Import;
@@ -146,8 +147,46 @@ bool checkExpectErrors(str mname, list[str] expected, PathConfig pcfg, list[Proj
146147
147148
TModel 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

Comments
 (0)