package function.builtin.math; import static testutil.TestUtilities.*; import org.junit.Test; import function.ArgumentValidator.BadArgumentTypeException; import sexpression.LispNumber; import testutil.SymbolAndFunctionCleaner; public class MULTIPLYTest extends SymbolAndFunctionCleaner { @Test public void multiplyWithNoArguments() { String input = "(*)"; assertSExpressionsMatch(new LispNumber("1"), evaluateString(input)); } @Test public void multiplyWithOneNumber() { String input = "(* 8)"; assertSExpressionsMatch(new LispNumber("8"), evaluateString(input)); } @Test public void multiplyWithTwoNumbers() { String input = "(* 5 3)"; assertSExpressionsMatch(new LispNumber("15"), evaluateString(input)); } @Test public void multiplyWithManyNumbers_PositiveResult() { String input = "(* 2 3 5 1)"; assertSExpressionsMatch(new LispNumber("30"), evaluateString(input)); } @Test public void multiplyWithManyNumbers_NegativeResult() { String input = "(* 3 (- 2) 10 2)"; assertSExpressionsMatch(new LispNumber("-120"), evaluateString(input)); } @Test(expected = BadArgumentTypeException.class) public void multiplyWithNonNumber() { evaluateString("(* 'a 'b)"); } }