Package ro.redeul.google.go.lang.psi.expressions.primary

Examples of ro.redeul.google.go.lang.psi.expressions.primary.GoSliceExpression


public class GoPsiSliceExpressionsTestCase extends GoPsiTestCase {

    public void testNormalSlice() throws Exception {
        GoFile file = get(parse("package main; func a() { a[i:j] }"));

        GoSliceExpression sliceExpression =
            getAs(GoSliceExpression.class,
                  castAs(GoExpressionStatement.class, 0,
                         get(
                             childAt(0,
                                     file.getFunctions()
                             ).getBlock()
                         ).getStatements()
                  ).getExpression()
            );

        assertEquals("a", get(sliceExpression.getBaseExpression()).getText());
        assertEquals("i", get(sliceExpression.getFirstIndex()).getText());
        assertEquals("j", get(sliceExpression.getSecondIndex()).getText());
    }
View Full Code Here


    }

    public void testNormalNewSlice() throws Exception {
        GoFile file = get(parse("package main; func a() { a[i:j:k] }"));

        GoSliceExpression sliceExpression =
                getAs(GoSliceExpression.class,
                        castAs(GoExpressionStatement.class, 0,
                                get(
                                        childAt(0,
                                                file.getFunctions()
                                        ).getBlock()
                                ).getStatements()
                        ).getExpression()
                );

        assertEquals("a", get(sliceExpression.getBaseExpression()).getText());
        assertEquals("i", get(sliceExpression.getFirstIndex()).getText());
        assertEquals("j", get(sliceExpression.getSecondIndex()).getText());
        assertEquals("k", get(sliceExpression.getCapacity()).getText());
    }
View Full Code Here

    public void testEmptySlice() throws Exception {
        GoFile file = get(parse("package main; func a() { a[:] }"));


        GoSliceExpression sliceExpression =
            getAs(GoSliceExpression.class,
                  castAs(GoExpressionStatement.class, 0,
                         get(
                             childAt(0,
                                     file.getFunctions()
                             ).getBlock()
                         ).getStatements()
                  ).getExpression()
            );

        assertEquals("a", get(sliceExpression.getBaseExpression()).getText());
        assertNull(sliceExpression.getFirstIndex());
        assertNull(sliceExpression.getSecondIndex());
        assertNull(sliceExpression.getCapacity());
    }
View Full Code Here

    public void testSliceFirstIndex() throws Exception {
        GoFile file = get(parse("package main; func a() { a[i:] }"));


        GoSliceExpression sliceExpression =
            getAs(GoSliceExpression.class,
                  castAs(GoExpressionStatement.class, 0,
                         get(
                             childAt(0,
                                     file.getFunctions()
                             ).getBlock()
                         ).getStatements()
                  ).getExpression()
            );

        assertEquals("a", get(sliceExpression.getBaseExpression()).getText());
        assertEquals("i", get(sliceExpression.getFirstIndex()).getText());
        assertNull(sliceExpression.getSecondIndex());
        assertNull(sliceExpression.getCapacity());
    }
View Full Code Here

    public void testSliceSecondIndex() throws Exception {
        GoFile file = get(parse("package main; func a() { a[:j] }"));


        GoSliceExpression sliceExpression =
            getAs(GoSliceExpression.class,
                  castAs(GoExpressionStatement.class, 0,
                         get(
                             childAt(0,
                                     file.getFunctions()
                             ).getBlock()
                         ).getStatements()
                  ).getExpression()
            );

        assertEquals("a", get(sliceExpression.getBaseExpression()).getText());
        assertNull(sliceExpression.getFirstIndex());
        assertEquals("j", get(sliceExpression.getSecondIndex()).getText());
        assertNull(sliceExpression.getCapacity());
    }
View Full Code Here

    }
    public void testSliceCapacity() throws Exception {
        GoFile file = get(parse("package main; func a() { a[:j:k] }"));


        GoSliceExpression sliceExpression =
            getAs(GoSliceExpression.class,
                  castAs(GoExpressionStatement.class, 0,
                         get(
                             childAt(0,
                                     file.getFunctions()
                             ).getBlock()
                         ).getStatements()
                  ).getExpression()
            );

        assertEquals("a", get(sliceExpression.getBaseExpression()).getText());
        assertNull(sliceExpression.getFirstIndex());
        assertEquals("j", get(sliceExpression.getSecondIndex()).getText());
        assertEquals("k", get(sliceExpression.getCapacity()).getText());
    }
View Full Code Here

                                    "package main; func a() { " +
                                    "   ad[\n" +
                                    "/**/ 1/**/:/**/2/**/] }\n" +
                                    ""));

        GoSliceExpression sliceExpression =
            getAs(GoSliceExpression.class,
                  castAs(GoExpressionStatement.class, 0,
                         get(
                             childAt(0,
                                     file.getFunctions()
                             ).getBlock()
                         ).getStatements()
                  ).getExpression()
            );

        assertEquals("ad", get(sliceExpression.getBaseExpression()).getText());
        assertEquals("1", get(sliceExpression.getFirstIndex()).getText());
        assertEquals("2", get(sliceExpression.getSecondIndex()).getText());
    }
View Full Code Here

                "package main; func a() { " +
                "   ad[\n" +
                "/**/ 1/**/:/**/2/**/:/**/3/**/] }\n" +
                ""));

        GoSliceExpression sliceExpression =
                getAs(GoSliceExpression.class,
                        castAs(GoExpressionStatement.class, 0,
                                get(
                                        childAt(0,
                                                file.getFunctions()
                                        ).getBlock()
                                ).getStatements()
                        ).getExpression()
                );

        assertEquals("ad", get(sliceExpression.getBaseExpression()).getText());
        assertEquals("1", get(sliceExpression.getFirstIndex()).getText());
        assertEquals("2", get(sliceExpression.getSecondIndex()).getText());
        assertEquals("3", get(sliceExpression.getCapacity()).getText());
    }
View Full Code Here

TOP

Related Classes of ro.redeul.google.go.lang.psi.expressions.primary.GoSliceExpression

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.