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);
}
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);
}
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;
}