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.assertTrue;

class NameTableTest {

    @Test
    void shouldInternEqualNamesToSameIdentifier() {
        final var table = new NameTable();

        final var first = table.register("sum");
        final var second = table.register("sum");
        final var third = table.register("tick");

        assertEquals(first, second);
        assertEquals(2, table.size());
        assertTrue(table.containsKey("sum"));
        assertEquals("tick", table.get(third));
    }
}
