aboutsummaryrefslogtreecommitdiffstats
path: root/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/parser/PrecedenceTestCase.java
blob: fe2c0ae302509fd4f5d4fb9bacc16dcd42114d94 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.indexinglanguage.parser;

import com.yahoo.vespa.indexinglanguage.expressions.Expression;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * @author Simon Thoresen Hult
 */
public class PrecedenceTestCase {

    @Test
    public void requireThatMathPrecedesConcat() throws ParseException {
        assertEquals("15", evaluate("1 . 2 + 3"));
        assertEquals("33", evaluate("1 + 2 . 3"));
    }

    private static String evaluate(String script) throws ParseException {
        return String.valueOf(Expression.fromString(script).execute());
    }
}