Package com.ericsson.otp.erlang

Examples of com.ericsson.otp.erlang.OtpErlangObject


        Assert.assertEquals(true, Util.isTag(input, "ok"));
    }

    @Test
    public void testIsTag_tuple_wrong_atom() throws TermParserException {
        final OtpErlangObject input = OtpErlang.getTermParser().parse("{okx, 9}");
        Assert.assertEquals(false, Util.isTag(input, "ok"));
    }
View Full Code Here


        Assert.assertEquals(false, Util.isTag(input, "ok"));
    }

    @Test
    public void stringValue_1() throws TermParserException {
        final OtpErlangObject input = OtpErlang.getTermParser().parse("\"a string\"");
        final String expected = "a string";
        final String actual = Util.stringValue(input);
        Assert.assertEquals(expected, actual);
    }
View Full Code Here

        Assert.assertEquals(expected, actual);
    }

    @Test
    public void stringValue_2() throws TermParserException {
        final OtpErlangObject input = OtpErlang.getTermParser().parse("[]");
        final String expected = "";
        final String actual = Util.stringValue(input);
        Assert.assertEquals(expected, actual);
    }
View Full Code Here

        Assert.assertEquals(expected, actual);
    }

    @Test
    public void stringValue_3() throws TermParserException {
        final OtpErlangObject input = OtpErlang.getTermParser().parse("[51,52,53]");
        final String expected = "345";
        final String actual = Util.stringValue(input);
        Assert.assertEquals(expected, actual);
    }
View Full Code Here

        Assert.assertEquals(expected, actual);
    }

    @Test
    public void stringValue_4() {
        final OtpErlangObject input = new OtpErlangBinary(new byte[] { 51, 52, 53 });
        final String expected = "345";
        final String actual = Util.stringValue(input);
        Assert.assertEquals(expected, actual);
    }
View Full Code Here

    }

    @Test
    public void stringValue_5() {
        final byte[] bytes = new byte[] { 197 - 256, 246 - 256 };
        final OtpErlangObject input = new OtpErlangBinary(bytes);
        final byte[] expected = bytes;
        final String actual = Util.stringValue(input);
        assertThat(actual.getBytes(Charsets.ISO_8859_1), is(expected));
    }
View Full Code Here

    }

    @Test
    public void stringValue_6() {
        final byte[] bytes = new byte[] { (byte) 0xE8, (byte) 0x8F, (byte) 0xAF };
        final OtpErlangObject input = new OtpErlangBinary(bytes);
        final byte[] expected = bytes;
        final String actual = Util.stringValue(input);
        assertThat(actual.getBytes(Charsets.UTF_8), is(expected));
    }
View Full Code Here

                final OtpErlangAtom tag = new OtpErlangAtom(getName());
                final OtpErlangAtom okey = new OtpErlangAtom(key);
                if (Strings.isNullOrEmpty(val)) {
                    defines[i] = OtpErlang.mkTuple(tag, okey);
                } else {
                    final OtpErlangObject ovalue = OtpErlang.getTermParser().parse(val);
                    defines[i] = OtpErlang.mkTuple(tag, okey, ovalue);
                }
            }
            return OtpErlang.mkList(defines);
        }
View Full Code Here

        final List<OtpErlangObject> result = new ArrayList<OtpErlangObject>();
        for (final CompilerOption option : CompilerOption.ALL_OPTIONS) {
            final Object optionValue = options.get(option);
            if (optionValue != null) {
                if (option instanceof BooleanOption) {
                    final OtpErlangObject val = ((BooleanOption) option)
                            .toTerm(((Boolean) optionValue).booleanValue());
                    if (val != null) {
                        result.add(val);
                    }
                } else if (option instanceof PathsOption) {
                    final Iterable<String> value = (Iterable<String>) optionValue;
                    final OtpErlangList val = (OtpErlangList) ((PathsOption) option)
                            .toTerm(value);
                    for (final OtpErlangObject inc : val.elements()) {
                        result.add(inc);
                    }
                } else if (option instanceof ModuleOption) {
                    final String value = (String) optionValue;
                    final OtpErlangObject val = ((ModuleOption) option).toTerm(value);
                    result.add(val);
                } else if (option instanceof RawOption) {
                    final String value = (String) optionValue;
                    final OtpErlangList val = (OtpErlangList) ((RawOption) option)
                            .toTerm(value);
                    for (final OtpErlangObject item : val.elements()) {
                        result.add(item);
                    }
                } else {
                    try {
                        final OtpErlangList val = ((DefineOption) option)
                                .toTerm((List<Pair<String, String>>) optionValue);
                        if (val != null) {
                            result.addAll(Lists.newArrayList(val.elements()));
                        }
                    } catch (final TermParserException e) {
                        ErlLogger.warn(e);
                    }
                }
View Full Code Here

            ErlLogger.warn("error compiling erl file: "
                    + resource.getResource().getProjectRelativePath());
            return;
        }
        try {
            final OtpErlangObject result = res.checkedGet();
            completeCompile(project, resource.getResource(), result, b, compilerOptions);
        } catch (final RpcException e) {
            ErlLogger.warn(e);
        }
    }
View Full Code Here

TOP

Related Classes of com.ericsson.otp.erlang.OtpErlangObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.