implements PR013
This commit is contained in:
+48
@@ -149,6 +149,54 @@ class PbsModuleVisibilityTest {
|
||||
assertTrue(importVisibilityDiagnostics.getFirst().getMessage().contains("secret"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldRejectImportFromMissingModule() {
|
||||
final var diagnostics = DiagnosticSink.empty();
|
||||
final var nextFileId = new AtomicInteger(0);
|
||||
|
||||
final var moduleApp = module("core", "app", List.of(
|
||||
"""
|
||||
import { open } from @core:missing;
|
||||
fn use() -> int { return 1; }
|
||||
"""
|
||||
), """
|
||||
pub fn use() -> int;
|
||||
""", nextFileId, diagnostics);
|
||||
|
||||
new PbsModuleVisibilityValidator().validate(ReadOnlyList.wrap(List.of(moduleApp)), diagnostics);
|
||||
|
||||
assertTrue(diagnostics.stream().anyMatch(d ->
|
||||
d.getCode().equals(PbsLinkErrors.E_LINK_IMPORT_MODULE_NOT_FOUND.name())));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldRejectImportOfUnknownSymbol() {
|
||||
final var diagnostics = DiagnosticSink.empty();
|
||||
final var nextFileId = new AtomicInteger(0);
|
||||
|
||||
final var moduleMath = module("core", "math", List.of(
|
||||
"""
|
||||
fn open() -> int { return 2; }
|
||||
"""
|
||||
), """
|
||||
pub fn open() -> int;
|
||||
""", nextFileId, diagnostics);
|
||||
|
||||
final var moduleApp = module("core", "app", List.of(
|
||||
"""
|
||||
import { missing } from @core:math;
|
||||
fn use() -> int { return 1; }
|
||||
"""
|
||||
), """
|
||||
pub fn use() -> int;
|
||||
""", nextFileId, diagnostics);
|
||||
|
||||
new PbsModuleVisibilityValidator().validate(ReadOnlyList.wrap(List.of(moduleMath, moduleApp)), diagnostics);
|
||||
|
||||
assertTrue(diagnostics.stream().anyMatch(d ->
|
||||
d.getCode().equals(PbsLinkErrors.E_LINK_IMPORT_SYMBOL_UNRESOLVED.name())));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldResolveBarrelFunctionWithResultReturnSurface() {
|
||||
final var diagnostics = DiagnosticSink.empty();
|
||||
|
||||
Reference in New Issue
Block a user