use of org.erlide.util.erlang.OtpBindings in project erlide_eclipse by erlang.
the class TestCaseData method parseReason.
private FailReason parseReason(final OtpErlangObject reason) {
OtpBindings b;
try {
b = OtpErlang.match("{Cause, Stack}", reason);
if (b == null) {
return new FailReason("internal error: " + reason.toString(), TestCaseData.NO_STACK);
}
final Collection<OtpErlangObject> stack = b.getList("Stack");
return new FailReason(b.get("Cause").toString(), stack);
} catch (final OtpParserException e) {
ErlLogger.warn(e);
} catch (final OtpErlangException e) {
ErlLogger.warn(e);
}
return null;
}
use of org.erlide.util.erlang.OtpBindings in project erlide_eclipse by erlang.
the class LogEventHandler method handleEvent.
@Subscribe
public void handleEvent(final ErlEvent event) {
if (!event.getTopic().equals(getTopic())) {
return;
}
final OtpErlangObject data = event.getEvent();
try {
final OtpBindings b = OtpErlang.match("{K:a,M}", data);
final String kind = ((OtpErlangAtom) b.get("K")).atomValue();
final OtpErlangObject amsg = b.get("M");
ErlLogger.debug("%s: %s", kind, OtpErlang.asString(amsg));
} catch (final Exception e) {
ErlLogger.error("erroneous log msg: %s", data);
}
}
use of org.erlide.util.erlang.OtpBindings in project erlide_eclipse by erlang.
the class PatternMatchTest method testMatch_sig_i.
@Test
public void testMatch_sig_i() throws Exception {
final OtpBindings r = OtpErlang.match("W:i", "222");
Assert.assertEquals(r.get("W"), new OtpErlangLong(222));
}
use of org.erlide.util.erlang.OtpBindings in project erlide_eclipse by erlang.
the class PatternMatchTest method testMatch_same_fail.
@Test
public void testMatch_same_fail() throws Exception {
final OtpBindings r = OtpErlang.match("[W, {W}]", "[a, {b}]");
Assert.assertNull(r);
}
use of org.erlide.util.erlang.OtpBindings in project erlide_eclipse by erlang.
the class PatternMatchTest method testMatch_novar.
@Test
public void testMatch_novar() throws Exception {
final OtpErlangObject p = OtpErlang.parse("[a, {b}]");
final OtpErlangObject t1 = OtpErlang.parse("[a, {b}]");
final OtpBindings r = OtpErlang.match(p, t1);
Assert.assertNotNull(r);
}
Aggregations