package p.studio.compiler.source.tables;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

class TypeSurfaceTableTest {

    @Test
    void shouldInternEqualSurfacesToSameIdentifier() {
        final var table = new TypeSurfaceTable();

        final var first = table.register("simple:int");
        final var second = table.register("simple:int");
        final var third = table.register("result<error>simple:int");

        assertEquals(first, second);
        assertEquals(2, table.size());
        assertEquals("result<error>simple:int", table.get(third).surface());
    }

    @Test
    void shouldRejectInvalidSurfaceContract() {
        assertThrows(IllegalArgumentException.class, () -> new TypeSurfaceRef(""));
    }
}
