Search in sources :

Example 46 with ValueEval

use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.

the class TestSlope method testLargeArrays.

/**
	 * number of items in array is not limited to 30
	 */
public void testLargeArrays() {
    // [1,2,0,1,2,0,...,0,1]
    ValueEval[] yValues = createMockNumberArray(100, 3);
    // Changes first element to 2
    yValues[0] = new NumberEval(2.0);
    // [1,2,3,4,...,99,100]
    ValueEval[] xValues = createMockNumberArray(100, 101);
    confirm(SLOPE, createAreaEval(xValues), createAreaEval(yValues), -1.231527093596059);
// Excel 2010 gives -1.23152709359606
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 47 with ValueEval

use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.

the class TestSlope method confirmError.

private void confirmError(Function function, ValueEval xArray, ValueEval yArray, ErrorEval expectedError) {
    ValueEval result = invoke(function, xArray, yArray);
    assertEquals(ErrorEval.class, result.getClass());
    assertEquals(expectedError.getErrorCode(), ((ErrorEval) result).getErrorCode());
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval)

Example 48 with ValueEval

use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.

the class TestPmt method test3args.

@Test
public void test3args() {
    ValueEval[] args = { new NumberEval(0.005), new NumberEval(24), new NumberEval(1000) };
    ValueEval ev = invoke(args);
    if (ev instanceof ErrorEval) {
        ErrorEval err = (ErrorEval) ev;
        if (err.getErrorCode() == FormulaError.VALUE.getCode()) {
            fail("Identified bug 44691");
        }
    }
    confirm(-44.3206, invokeNormal(args));
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) ErrorEval(org.apache.poi.ss.formula.eval.ErrorEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval) Test(org.junit.Test)

Example 49 with ValueEval

use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.

the class TestPoisson method invokePoisson.

private static ValueEval invokePoisson(double x, double mean, boolean cumulative) {
    ValueEval[] valueEvals = new ValueEval[3];
    valueEvals[0] = new NumberEval(x);
    valueEvals[1] = new NumberEval(mean);
    valueEvals[2] = BoolEval.valueOf(cumulative);
    return NumericFunction.POISSON.evaluate(valueEvals, -1, -1);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 50 with ValueEval

use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.

the class TestQuotient method confirmValue.

private static void confirmValue(String msg, String numerator, String denominator, String expected) {
    ValueEval result = invokeValue(numerator, denominator);
    assertEquals(NumberEval.class, result.getClass());
    assertEquals(msg, expected, ((NumberEval) result).getStringValue());
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval)

Aggregations

ValueEval (org.apache.poi.ss.formula.eval.ValueEval)223 NumberEval (org.apache.poi.ss.formula.eval.NumberEval)101 StringEval (org.apache.poi.ss.formula.eval.StringEval)48 Test (org.junit.Test)39 EvaluationException (org.apache.poi.ss.formula.eval.EvaluationException)36 AreaEval (org.apache.poi.ss.formula.eval.AreaEval)29 NumericValueEval (org.apache.poi.ss.formula.eval.NumericValueEval)28 OperationEvaluationContext (org.apache.poi.ss.formula.OperationEvaluationContext)27 Calendar (java.util.Calendar)16 ErrorEval (org.apache.poi.ss.formula.eval.ErrorEval)13 Date (java.util.Date)11 RefEval (org.apache.poi.ss.formula.eval.RefEval)9 TwoDEval (org.apache.poi.ss.formula.TwoDEval)7 BlankEval (org.apache.poi.ss.formula.eval.BlankEval)4 NotImplementedException (org.apache.poi.ss.formula.eval.NotImplementedException)4 StringValueEval (org.apache.poi.ss.formula.eval.StringValueEval)4 ValueVector (org.apache.poi.ss.formula.functions.LookupUtils.ValueVector)4 ArrayList (java.util.ArrayList)3 AssertionFailedError (junit.framework.AssertionFailedError)3 BoolEval (org.apache.poi.ss.formula.eval.BoolEval)3