Package ro.redeul.google.go.psi

Source Code of ro.redeul.google.go.psi.GoPsiBuiltinCallExpressionTest

package ro.redeul.google.go.psi;

import ro.redeul.google.go.GoPsiTestCase;
import ro.redeul.google.go.lang.psi.GoFile;
import ro.redeul.google.go.lang.psi.expressions.primary.GoBuiltinCallOrConversionExpression;
import ro.redeul.google.go.lang.psi.types.GoPsiTypeName;
import static ro.redeul.google.go.util.GoPsiTestUtils.castAs;
import static ro.redeul.google.go.util.GoPsiTestUtils.childAt;
import static ro.redeul.google.go.util.GoPsiTestUtils.get;
import static ro.redeul.google.go.util.GoPsiTestUtils.getAs;

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());
        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());
        assertEquals(builtin.getArguments().length, 1);
    }
}
TOP

Related Classes of ro.redeul.google.go.psi.GoPsiBuiltinCallExpressionTest

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.