package sterling.lang.expression;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import static sterling.lang.expression.ExpressionFactory.conditional;
import static sterling.lang.expression.ExpressionFactory.constant;

import org.junit.Before;
import org.junit.Test;
import sterling.lang.SterlingException;

public class ConditionalTest {

    private Expression trueConditional;
    private Expression falseConditional;

    @Before
    public void setUp() {
        trueConditional = conditional(constant(true), constant("apples"), constant("bananas"));
        falseConditional = conditional(constant(false), constant("apples"), constant("bananas"));
    }

    @Test
    public void shouldGiveApples_whenConditionalIsTrue() throws SterlingException {
        assertThat(trueConditional.reduce(), equalTo((Expression) constant("apples")));
    }

    @Test
    public void shouldGiveBananas_whenConditionalIsFalse() throws SterlingException {
        assertThat(falseConditional.reduce(), equalTo((Expression) constant("bananas")));
    }
}
