package function.builtin.math;

import static testutil.TestUtilities.*;

import org.junit.Test;

import function.ArgumentValidator.BadArgumentTypeException;
import sexpression.LispNumber;

public class MULTIPLYTester {

    @Test
    public void testMultiplyWithNoArguments() {
        String input = "(*)";

        assertSExpressionsMatch(new LispNumber("1"), evaluateString(input));
    }

    @Test
    public void testMultiplyWithOneNumber() {
        String input = "(* 8)";

        assertSExpressionsMatch(new LispNumber("8"), evaluateString(input));
    }

    @Test
    public void testMultiplyWithTwoNumbers() {
        String input = "(* 5 3)";

        assertSExpressionsMatch(new LispNumber("15"), evaluateString(input));
    }

    @Test
    public void testMultiplyWithManyNumbers_PositiveResult() {
        String input = "(* 2 3 5 1)";

        assertSExpressionsMatch(new LispNumber("30"), evaluateString(input));
    }

    @Test
    public void testMultiplyWithManyNumbers_NegativeResult() {
        String input = "(* 3 (- 2) 10 2)";

        assertSExpressionsMatch(new LispNumber("-120"), evaluateString(input));
    }

    @Test(expected = BadArgumentTypeException.class)
    public void testMultiplyWithNonNumber() {
        evaluateString("(* 'a 'b)");
    }

}
