Search in sources :

Example 31 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.

the class PatternMatchTest method testMatch_1.

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

Example 32 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.

the class TermParserTest method string_2.

@Test
public void string_2() throws OtpParserException {
    final OtpErlangString r = (OtpErlangString) termParser.parse("\"Hello world!\"");
    Assert.assertEquals(r.stringValue(), "Hello world!");
}
Also used : OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) Test(org.junit.Test)

Example 33 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.

the class UtilTest method testIoListToString_small.

@Test
public void testIoListToString_small() {
    final OtpErlangObject input = OtpErlang.mkList(new OtpErlangString("hej"), new OtpErlangString("hoj"));
    final String result = Util.ioListToString(input, 10);
    final String expected = "hejhoj";
    Assert.assertEquals(expected, result);
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) Test(org.junit.Test)

Example 34 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.

the class UtilTest method testIoListToString_large1.

@Test
public void testIoListToString_large1() {
    final OtpErlangObject input = OtpErlang.mkList(new OtpErlangString("hej"), new OtpErlangString("hoj"));
    final String result = Util.ioListToString(input, 4);
    final String expected = "hejh... <truncated>";
    Assert.assertEquals(expected, result);
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) Test(org.junit.Test)

Example 35 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.

the class CommandData method addUserInput.

// non-interactive
public void addUserInput(final List<String> input) {
    final List<OtpErlangObject> argsTmp = new LinkedList<>();
    final OtpErlangObject[] userInput = new OtpErlangObject[input.size()];
    int i = 0;
    for (final String text : input) {
        userInput[i] = new OtpErlangString(text);
        i++;
    }
    for (final OtpErlangObject arg : args) {
        if (arg instanceof OtpErlangTuple && ((OtpErlangTuple) arg).elementAt(0).equals(new OtpErlangAtom("prompt"))) {
            argsTmp.add(new OtpErlangList(userInput));
        // TODO make it so that it adds input only once, check repeat
        // interactive
        } else {
            argsTmp.add(arg);
        }
    }
    args = argsTmp.toArray(new OtpErlangObject[0]);
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) LinkedList(java.util.LinkedList) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Aggregations

OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)56 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)36 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)31 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)22 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)15 ArrayList (java.util.ArrayList)9 RpcResult (org.erlide.runtime.rpc.RpcResult)8 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)7 RpcException (org.erlide.runtime.rpc.RpcException)7 Test (org.junit.Test)7 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)6 OtpErlangBinary (com.ericsson.otp.erlang.OtpErlangBinary)5 IPath (org.eclipse.core.runtime.IPath)5 ErlModelException (org.erlide.engine.model.ErlModelException)5 IErlElement (org.erlide.engine.model.IErlElement)5 WranglerRpcParsingException (org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException)5 IErlMemberSelection (org.erlide.wrangler.refactoring.selection.IErlMemberSelection)5 CoreException (org.eclipse.core.runtime.CoreException)4 WranglerException (org.erlide.wrangler.refactoring.exception.WranglerException)4 Map (java.util.Map)3