Search in sources :

Example 1 with Exports

use of org.elixir_lang.beam.chunk.Exports in project intellij-elixir by KronicDeth.

the class BeamTest method elixirModule.

@Test
public void elixirModule() throws IOException, OtpErlangDecodeException {
    Beam beam = beam("Elixir.Kernel");
    assertNotNull(beam);
    Atoms atoms = beam.atoms();
    assertNotNull(atoms);
    assertEquals("Elixir.Kernel", atoms.moduleName());
    Exports exports = beam.exports();
    assertNotNull(exports);
    int exportCount = exports.size();
    assertTrue("There are no exports", exportCount > 0);
    SortedSet<MacroNameArity> macroNameAritySortedSet = exports.macroNameAritySortedSet(atoms);
    assertEquals("There are nameless exports", exportCount, macroNameAritySortedSet.size());
    List<MacroNameArity> nodes = ContainerUtil.filter(macroNameAritySortedSet, new Condition<MacroNameArity>() {

        @Override
        public boolean value(MacroNameArity macroNameArity) {
            return "node".equals(macroNameArity.name);
        }
    });
    assertEquals(nodes.size(), 2);
    assertEquals(0, (int) nodes.get(0).arity);
    assertEquals(1, (int) nodes.get(1).arity);
}
Also used : Atoms(org.elixir_lang.beam.chunk.Atoms) Exports(org.elixir_lang.beam.chunk.Exports) Test(org.junit.Test)

Example 2 with Exports

use of org.elixir_lang.beam.chunk.Exports in project intellij-elixir by KronicDeth.

the class BeamTest method erlangModule.

@Test
public void erlangModule() throws IOException, OtpErlangDecodeException {
    Beam beam = beam("elixir_interpolation");
    assertNotNull(beam);
    Atoms atoms = beam.atoms();
    assertNotNull(atoms);
    assertEquals("elixir_interpolation", atoms.moduleName());
    Exports exports = beam.exports();
    assertNotNull(exports);
    int exportCount = exports.size();
    assertTrue("There are no exports", exportCount > 0);
    SortedSet<MacroNameArity> macroNameAritySortedSet = exports.macroNameAritySortedSet(atoms);
    assertEquals("There are nameless exports", exportCount, macroNameAritySortedSet.size());
    List<MacroNameArity> extracts = ContainerUtil.filter(macroNameAritySortedSet, new Condition<MacroNameArity>() {

        @Override
        public boolean value(MacroNameArity macroNameArity) {
            return "extract".equals(macroNameArity.name);
        }
    });
    assertEquals(1, extracts.size());
    assertEquals(6, (int) extracts.get(0).arity);
}
Also used : Atoms(org.elixir_lang.beam.chunk.Atoms) Exports(org.elixir_lang.beam.chunk.Exports) Test(org.junit.Test)

Example 3 with Exports

use of org.elixir_lang.beam.chunk.Exports in project intellij-elixir by KronicDeth.

the class Beam method exports.

@Nullable
public Exports exports() {
    Exports exports = null;
    Chunk chunk = chunk(EXPT);
    if (chunk != null) {
        exports = Exports.from(chunk);
    }
    return exports;
}
Also used : Chunk(org.elixir_lang.beam.chunk.Chunk) Exports(org.elixir_lang.beam.chunk.Exports) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Exports (org.elixir_lang.beam.chunk.Exports)3 Atoms (org.elixir_lang.beam.chunk.Atoms)2 Test (org.junit.Test)2 Chunk (org.elixir_lang.beam.chunk.Chunk)1 Nullable (org.jetbrains.annotations.Nullable)1