aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/shedlang/compiler/parser/ParserVarTests.java
blob: d43b4ca648bea482f93147cd0c51d72549564fe2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package org.shedlang.compiler.parser;

import org.junit.jupiter.api.Test;

import static org.shedlang.compiler.ast.untyped.UntypedNodeMatchers.*;
import static org.shedlang.compiler.parser.ParserTesting.parseString;
import static org.zwobble.precisely.AssertThat.assertThat;

public class ParserVarTests {
    @Test
    public void canParseVarAsFunctionStatement() {
        var source = "var x = y;";

        var node = parseString(source, Parser::parseFunctionStatement);

        assertThat(node, isUntypedAssignNode(
            isUntypedTargetVarNode("x"),
            isUntypedReferenceNode("y")
        ));
    }
}