Package org.erlide.util.erlang

Examples of org.erlide.util.erlang.Bindings


        Assert.assertNotNull(r);
    }

    @Test
    public void testMatch_same_fail() throws Exception {
        final Bindings r = OtpErlang.match("[W, {W}]", "[a, {b}]");
        Assert.assertNull(r);
    }
View Full Code Here


        Assert.assertNull(r);
    }

    @Test
    public void testMatch_sig_a() throws Exception {
        final Bindings r = OtpErlang.match("W:a", "zzz");
        Assert.assertEquals(r.get("W"), new OtpErlangAtom("zzz"));
    }
View Full Code Here

        Assert.assertEquals(r.get("W"), new OtpErlangAtom("zzz"));
    }

    @Test
    public void testMatch_sig_i() throws Exception {
        final Bindings r = OtpErlang.match("W:i", "222");
        Assert.assertEquals(r.get("W"), new OtpErlangLong(222));
    }
View Full Code Here

        Assert.assertEquals(r.get("W"), new OtpErlangLong(222));
    }

    @Test
    public void testMatch_sig_fail() throws Exception {
        final Bindings r = OtpErlang.match("W:i", "zzz");
        Assert.assertNull(r);
    }
View Full Code Here

        Assert.assertNotNull(r);
    }

    @Test
    public void testMatch_ellipsis_2() throws Exception {
        final Bindings r = OtpErlang.match("[X | T]", "[x,y,z]");
        Assert.assertNotNull(r);
        Assert.assertEquals(new OtpErlangAtom("x"), r.get("X"));
        Assert.assertEquals(termParser.parse("[y,z]"), r.get("T"));
    }
View Full Code Here

        Assert.assertEquals(termParser.parse("[y,z]"), r.get("T"));
    }

    @Test()
    public void testMatch_ellipsis_4() throws Exception {
        final Bindings r = OtpErlang.match("[X | y]", "[x,y,z]");
        Assert.assertNull(r);
    }
View Full Code Here

        OtpErlang.match("[X | Y, Z]", "[x,y,z]");
    }

    @Test
    public void testMatch_t() throws Exception {
        final Bindings r = OtpErlang.match("[W:a, V:i]", "[a, 1]");
        Assert.assertEquals(r.getAs("W", String.class), "a");
        Assert.assertEquals(r.getAs("V", Integer.class), Integer.valueOf(1));
    }
View Full Code Here

    try {
      TextRange _xblockexpression = null;
      {
        Iterable<OtpErlangObject> _tail = IterableExtensions.<OtpErlangObject>tail(this.items);
        OtpErlangObject _head = IterableExtensions.<OtpErlangObject>head(_tail);
        final Bindings pos = OtpErlang.match("{{Line,Offset,FileOffset},Len}", _head);
        int _int = pos.getInt("FileOffset");
        int _int_1 = pos.getInt("Len");
        _xblockexpression = new TextRange(_int, _int_1);
      }
      return _xblockexpression;
    } catch (Throwable _e) {
      throw Exceptions.sneakyThrow(_e);
View Full Code Here

            treeViewer.getTree().setCursor(
                    treeViewer.getTree().getShell().getDisplay()
                            .getSystemCursor(SWT.CURSOR_ARROW));
        } else if ("start".equals(tag)) {
            // value = {Module, Function}
            final Bindings bindings = OtpErlang.match("{M:a,F:a}", value);
            final String mod = bindings.getAtom("M");
            final String fun = bindings.getAtom("F");
            test = findCase(mod, fun);
            test.setRunning();
        } else if ("result".equals(tag)) {
            // value = {Module, Function, Result}
            final Bindings bindings = OtpErlang.match("{M:a,F:a,R}", value);
            final String mod = bindings.getAtom("M");
            final String fun = bindings.getAtom("F");
            final OtpErlangObject result = bindings.get("R");
            test = findCase(mod, fun);
            if (result instanceof OtpErlangAtom) {
                test.setSuccesful();
                // } else {
                // final BindingsImpl bindings =
                // OtpErlang.match("{failure,{M:a,F:a},L,R}", result);
                // final OtpErlangObject locations = bindings.get("L");
                // final OtpErlangObject reason = bindings.get("R");
                // test.setFailed(reason, locations);
            }
        } else if ("fail".equals(tag)) {
            // value = {{Module, Function}, [Locations], Reason
            final Bindings bindings = OtpErlang.match("{{M:a,F:a},L,R}", value);
            final String mod = bindings.getAtom("M");
            final String fun = bindings.getAtom("F");
            final Collection<OtpErlangObject> locations = bindings.getList("L");
            final OtpErlangObject reason = bindings.get("R");
            test = findCase(mod, fun);
            test.setFailed(reason, locations);
        } else if ("skip".equals(tag)) {
            // value = {Module, Function, Comment
            final Bindings bindings = OtpErlang.match("{M:a,F:a,C}", value);
            final String mod = bindings.getAtom("M");
            final String fun = bindings.getAtom("F");
            final OtpErlangObject reason = bindings.get("C");
            test = findCase(mod, fun);
            test.setSkipped(reason);
        } else if ("done".equals(tag)) {
            // value = Module, Log, {Successful,Failed,Skipped}, [Results]}
            final Bindings bindings = OtpErlang.match("{M,L,{S:i,F:i,K:i},R}", value);
            final int successful = bindings.getInt("S");
            final int failed = bindings.getInt("F");
            final int skipped = bindings.getInt("K");
            label.setText(label.getText() + " -- Done! Successful: " + successful
                    + ", Failed: " + failed + ", Skipped: " + skipped);
        }
        control.redraw();
    }
View Full Code Here

        control.redraw();
    }

    private String formatTitle(final OtpErlangObject value) {
        try {
            final Bindings b = OtpErlang.match("{D,S,C}", value);
            final String suite = b.getAtom("S");
            final String tcase = b.getAtom("C");
            if (tcase.length() == 0) {
                return "suite " + suite;
            }
            return "suite " + suite + "; case " + tcase;
        } catch (final TermParserException e) {
View Full Code Here

TOP

Related Classes of org.erlide.util.erlang.Bindings

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.