package no.ssb.vtl.parser;

/*-
 * ========================LICENSE_START=================================
 * Java VTL
 * %%
 * Copyright (C) 2016 - 2017 Hadrien Kohl
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =========================LICENSE_END==================================
 */


import org.junit.Test;

public class FunctionCallParserTest extends GrammarTest {

    @Test
    public void testFunction() throws Exception {
        parse("somefunction()", "functionCall");
        parse("one(two(three(four(123, \"string\", 132.0), five(), false), null))", "functionCall");
    }

    @Test
    public void testFunctionInStart() throws Exception {
        parse("variable := aFunction123()", "start");
    }
}

@@ -830,191 +830,1180 @@
 st;%0A
-%0Apublic class FunctionCallParserTest extends GrammarTest %7B%0A%0A    @Test%0A    public void testFunction() throws Exception %7B%0A        parse(%22somefunction()%22, %22functionCall%22);%0A        parse(
+import org.junit.runner.RunWith;%0Aimport org.junit.runners.Parameterized;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Collection;%0A%0Aimport static org.junit.runners.Parameterized.Parameter;%0Aimport static org.junit.runners.Parameterized.Parameters;%0A%0A@RunWith(Parameterized.class)%0Apublic class FunctionCallParserTest extends GrammarTest %7B%0A%0A    @Parameter(0)%0A    public String expression;%0A%0A    @Parameter(1)%0A    public String rule;%0A%0A%0A    @Parameters(name = %22%7Bindex%7D: parse %5C%22%7B0%7D%5C%22 with rule %7B1%7D%22)%0A    public static Collection%3CObject%5B%5D%3E functionCalls() %7B%0A        return Arrays.asList(new Object%5B%5D%5B%5D%7B%0A                %7B%22func()%22, %22functionCall%22%7D,%0A                %7B%22func(param1)%22, %22functionCall%22%7D,%0A                %7B%22func(param1, param2, param3)%22, %22functionCall%22%7D,%0A                %7B%22func(namedParam1: expr)%22, %22functionCall%22%7D,%0A                %7B%22func(namedParam1: expr,namedParam2: expr, namedParam3: expr)%22, %22functionCall%22%7D,%0A                %7B%22func(param1, namedParam1: expr)%22, %22functionCall%22%7D,%0A                %7B%22func(param1, param2, param3, namedParam1: expr,namedParam2: expr, namedParam3: expr)%22, %22functionCall%22%7D,%0A%0A                %7B%22somefunction()%22, %22functionCall%22%7D,%0A                %7B
 %22one
@@ -2082,16 +2082,84 @@
 ionCall%22
+%7D,%0A                %7B%22variable := aFunction123()%22, %22start%22%7D%0A        %7D
 );%0A    %7D
@@ -2202,15 +2202,8 @@
 tion
-InStart
 () t
@@ -2238,45 +2238,24 @@
 rse(
-%22variable := aFunction123()%22, %22start%22
+expression, rule
 );%0A 

Add more function call tests