Search in sources :

Example 21 with OtpBindings

use of org.erlide.util.erlang.OtpBindings in project erlide_eclipse by erlang.

the class PatternMatchTest method testMatch_0.

@Test
public void testMatch_0() throws Exception {
    final OtpBindings b = new OtpBindings();
    b.put("W", new OtpErlangAtom("a"));
    final OtpBindings r = OtpErlang.match("[W, V]", "[a, b]", b);
    Assert.assertNotNull(r);
    Assert.assertEquals(r.get("V"), new OtpErlangAtom("b"));
}
Also used : OtpBindings(org.erlide.util.erlang.OtpBindings) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) Test(org.junit.Test)

Example 22 with OtpBindings

use of org.erlide.util.erlang.OtpBindings in project erlide_eclipse by erlang.

the class PatternMatchTest method testMatch_ellipsis_4.

@Test()
public void testMatch_ellipsis_4() throws Exception {
    final OtpBindings r = OtpErlang.match("[X | y]", "[x,y,z]");
    Assert.assertNull(r);
}
Also used : OtpBindings(org.erlide.util.erlang.OtpBindings) Test(org.junit.Test)

Example 23 with OtpBindings

use of org.erlide.util.erlang.OtpBindings in project erlide_eclipse by erlang.

the class PatternMatchTest method testMatch.

@Test
public void testMatch() throws Exception {
    final OtpBindings r = OtpErlang.match("[W, V]", "[a, b]");
    Assert.assertEquals(r.get("W"), new OtpErlangAtom("a"));
    Assert.assertEquals(r.get("V"), new OtpErlangAtom("b"));
}
Also used : OtpBindings(org.erlide.util.erlang.OtpBindings) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) Test(org.junit.Test)

Example 24 with OtpBindings

use of org.erlide.util.erlang.OtpBindings in project erlide_eclipse by erlang.

the class ErlideDebug method setVariableValue.

@SuppressWarnings("boxing")
public static String setVariableValue(final IOtpRpc backend, final String name, final String value, final int stackFrameNo, final OtpErlangPid meta) {
    try {
        final OtpErlangObject res = backend.call(ErlideDebug.ERLIDE_DEBUG, "set_variable_value", "ssix", name, value, stackFrameNo + 1, meta);
        try {
            final OtpBindings bind = OtpErlang.match("{eval_rsp, {'EXIT', Val}}", res);
            if (bind == null) {
                return null;
            }
            final String err = bind.getAsString("Val");
            return err;
        } catch (final OtpParserException e1) {
        }
        return null;
    } catch (final RpcException e) {
        ErlLogger.warn(e);
    }
    return "error";
}
Also used : OtpParserException(org.erlide.util.erlang.OtpParserException) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpBindings(org.erlide.util.erlang.OtpBindings) RpcException(org.erlide.runtime.rpc.RpcException)

Aggregations

OtpBindings (org.erlide.util.erlang.OtpBindings)24 Test (org.junit.Test)13 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)9 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)9 OtpParserException (org.erlide.util.erlang.OtpParserException)7 OtpErlangException (com.ericsson.otp.erlang.OtpErlangException)6 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)3 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)2 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)2 Collection (java.util.Collection)2 RpcException (org.erlide.runtime.rpc.RpcException)2 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)1 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 Subscribe (com.google.common.eventbus.Subscribe)1 ArrayList (java.util.ArrayList)1 ErlangFunction (org.erlide.engine.model.erlang.ErlangFunction)1 FunctionRef (org.erlide.engine.model.erlang.FunctionRef)1