Examples of GoFile


Examples of ro.redeul.google.go.lang.psi.GoFile

import static ro.redeul.google.go.util.GoPsiTestUtils.get;

public class GoPsiSwitchTypesTest extends GoPsiTestCase {

    public void testDefault() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "func main() int {\n" +
                      "     switch x.(type) {\n" +
                      "         default:\n" +
                      "             return 1\n" +
                      "     }\n" +
                      "     return nil\n" +
                      "}\n"));

        GoSwitchTypeStatement typeSwitch =
            castAs(GoSwitchTypeStatement.class, 0,
                   get(
                       get(
                           file.getMainFunction()
                       ).getBlock()
                   ).getStatements()
            );

        assertNull(typeSwitch.getSimpleStatement());
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

        assertEquals("return 1", castAs(GoReturnStatement.class, 0,
                                        clause.getStatements()).getText());
    }

    public void testWithStatement() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "func main() int {\n" +
                      "     switch x := 1; x.(type) {\n" +
                      "         default:\n" +
                      "             return x\n" +
                      "     }\n" +
                      "     return nil\n" +
                      "}\n"));

        GoSwitchTypeStatement exprSwitch =
            castAs(GoSwitchTypeStatement.class, 0,
                   get(
                       get(
                           file.getMainFunction()
                       ).getBlock()
                   ).getStatements()
            );

        assertEquals("x := 1", get(exprSwitch.getSimpleStatement()).getText());
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

        assertEquals("x",
                     get(exprSwitch.getTypeGuard().getExpression()).getText());
    }

    public void testClauses() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "func main() int {\n" +
                      "     switch x.(type) {\n" +
                      "         case int, float, T:\n" +
                      "             a := 1\n" +
                      "             return a\n" +
                      "         case complex32:\n" +
                      "             return x\n" +
                      "     }\n" +
                      "     return nil\n" +
                      "}\n"));

        GoSwitchTypeStatement exprSwitch =
            castAs(GoSwitchTypeStatement.class, 0,
                   get(
                       get(
                           file.getMainFunction()
                       ).getBlock()
                   ).getStatements()
            );

        assertNull(exprSwitch.getSimpleStatement());
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

public class GoPsiTypesTest extends GoPsiTestCase {


    public void testBasic() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "type T struct {\n" +
                      "    io.Reader\n" +
                      "}"));

        GoPsiTypeStruct structType =
            getAs(GoPsiTypeStruct.class,
                  childAt(0,
                          childAt(0,
                                  file.getTypeDeclarations()
                          ).getTypeSpecs()
                  ).getType()
            );

        assertEquals(0, structType.getFields().length);
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

        getAs(GoPsiTypeName.class, anonymousField.getType());
    }

    public void testAnonymousPointer() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "type T struct {\n" +
                      "    *io.Reader\n" +
                      "}"));

        GoPsiTypeStruct structType =
            getAs(GoPsiTypeStruct.class,
                  childAt(0,
                          childAt(0,
                                  file.getTypeDeclarations()
                          ).getTypeSpecs()
                  ).getType()
            );

        assertEquals(0, structType.getFields().length);
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

public class GoPsiExpressionTest extends GoPsiTestCase {

    private static final float DELTA = (float) 1e-5;

    public void testGetNumberValueFromExpression() throws Exception {
        GoFile file = get(
                parse("" +
                        "package main\n" +
                        "const (\n" +
                        "     x0 = 100\n" +
                        "     x1 = 101.0\n" +
                        "     x2 = 102.3456\n" +
                        "     x3 = 'g'\n" +
                        "     x4 = -104\n" +
                        "     x5 = 50 + 55\n" +
                        "     x6 = (206 - (50 + 50))\n" +
                        "     x7 = 5 * 10 * 10 / 5 + 7\n" +
                        "     x8 = 8 / 0\n" +
                        "     x9 = 9.0 / 0.0\n" +
                        "     x10 = 2213 / 20\n" +
                        "     x11 = 2233 / 20.\n" +
                        "     x12 = (50 + 50.) * 2 - (265 / 3) \n" +
                        "     x13 = 1 << 3.0 + 1.0 << 3\n" +
                        "     x14 = 1.2 << 3\n" +
                        "     x15 = 1 << 3.1\n" +
                        "     x16 = ^-17\n" +
                        "     x17 = ^-18.0\n" +

                        ")"));

        GoConstDeclaration[] declarations =
                childAt(0,
                        file.getConsts()
                ).getDeclarations();

        Number val = null;

        val = FunctionCallInspection.getNumberValueFromLiteralExpr(childAt(0, declarations[0].getExpressions()));
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

        assertNull(val);

    }

    public void testGetNumberValueFromIotaExpression() throws Exception {
        GoFile file = get(
                parse("" +
                        "package main\n" +
                        "const (\n" +
                        "     x01, x02 = iota, iota * 2\n" +
                        "     x11, x12\n" +
                        "     x21, x22 = x11 + 2, x12 + 3\n" +
                        "     x31, x32 = (iota * 2.0), -iota\n" +

                        ")"));

        GoConstDeclaration[] declarations =
                childAt(0,
                        file.getConsts()
                ).getDeclarations();

        Number val;

        val = FunctionCallInspection.getNumberValueFromLiteralExpr(declarations[0].getExpression(declarations[0].getIdentifiers()[0]));
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

public class GoPsiFloatTest extends GoPsiTestCase {


    public void testBasic() throws Exception {
        GoFile file = get(
                parse("" +
                        "package main\n" +
                        "var (\n" +
                        "     x = 10.0\n" +
                        "     x1 = .25\n" +
                        "     y = 0.\n" +
                        "     z = 072.40\n" +
                        "     e1 = 1.e+0\n" +
                        "     e2 = 6.67428e-11\n" +
                        "     e3 = 1E6\n" +
//                        "     h2 = 0XAB\n" +
                        "}"));

        GoVarDeclaration[] declarations =
                childAt(0,
                        file.getGlobalVariables()
                ).getDeclarations();

        GoLiteralFloat fl;

        // x
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

public class GoPsiBuiltinCallExpressionTest extends GoPsiTestCase {


    public void testNew() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "var e = new(int)"));

        GoBuiltinCallOrConversionExpression builtin =
            castAs(GoBuiltinCallOrConversionExpression.class, 0,
                 childAt(0,
                         childAt(0,
                                 file.getGlobalVariables()
                         ).getDeclarations()
                 ).getExpressions()
            );

        assertEquals("int", getAs(GoPsiTypeName.class, builtin.getTypeArgument()).getText());
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

        assertEquals("int", getAs(GoPsiTypeName.class, builtin.getTypeArgument()).getText());
        assertEquals("new", get(builtin.getBaseExpression()).getText());
    }

    public void testMake() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "var e = make(int, 1)"));

        GoBuiltinCallOrConversionExpression builtin =
            castAs(GoBuiltinCallOrConversionExpression.class, 0,
                 childAt(0,
                         childAt(0,
                                 file.getGlobalVariables()
                         ).getDeclarations()
                 ).getExpressions()
            );

        assertEquals("int", getAs(GoPsiTypeName.class, builtin.getTypeArgument()).getText());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.