added missing tests for Bug 55042: patch for missing function COMPLEX

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1488808 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2013-06-02 23:25:07 +00:00
parent 4d81d34d5d
commit ecb8b8240c
3 changed files with 17 additions and 5 deletions

View File

@ -15,9 +15,7 @@ import org.apache.poi.ss.formula.eval.NotImplementedException;
import org.apache.poi.ss.formula.eval.ValueEval; import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.function.FunctionMetadata; import org.apache.poi.ss.formula.function.FunctionMetadata;
import org.apache.poi.ss.formula.function.FunctionMetadataRegistry; import org.apache.poi.ss.formula.function.FunctionMetadataRegistry;
import org.apache.poi.ss.formula.functions.EDate; import org.apache.poi.ss.formula.functions.*;
import org.apache.poi.ss.formula.functions.FreeRefFunction;
import org.apache.poi.ss.formula.functions.Sumifs;
import org.apache.poi.ss.formula.udf.UDFFinder; import org.apache.poi.ss.formula.udf.UDFFinder;
import java.util.*; import java.util.*;
@ -74,7 +72,7 @@ public final class AnalysisToolPak implements UDFFinder {
r(m, "BIN2DEC", null); r(m, "BIN2DEC", null);
r(m, "BIN2HEX", null); r(m, "BIN2HEX", null);
r(m, "BIN2OCT", null); r(m, "BIN2OCT", null);
r(m, "COMPLEX", null); r(m, "COMPLEX", Complex.instance);
r(m, "CONVERT", null); r(m, "CONVERT", null);
r(m, "COUNTIFS", null); r(m, "COUNTIFS", null);
r(m, "COUPDAYBS", null); r(m, "COUPDAYBS", null);

View File

@ -1,5 +1,6 @@
package org.apache.poi.ss.formula.functions; package org.apache.poi.ss.formula.functions;
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.*; import org.apache.poi.ss.formula.eval.*;
/** /**
@ -30,7 +31,9 @@ import org.apache.poi.ss.formula.eval.*;
* *
* @author cedric dot walter @ gmail dot com * @author cedric dot walter @ gmail dot com
*/ */
public class Complex extends Var2or3ArgFunction { public class Complex extends Var2or3ArgFunction implements FreeRefFunction {
public static final FreeRefFunction instance = new Complex();
public static final String DEFAULT_SUFFIX = "i"; public static final String DEFAULT_SUFFIX = "i";
public static final String SUPPORTED_SUFFIX = "j"; public static final String SUPPORTED_SUFFIX = "j";
@ -116,4 +119,15 @@ public class Complex extends Var2or3ArgFunction {
return (number == Math.floor(number)) && !Double.isInfinite(number); return (number == Math.floor(number)) && !Double.isInfinite(number);
} }
@Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length == 2) {
return evaluate(ec.getRowIndex(), ec.getColumnIndex(), args[0], args[1]);
}
if (args.length == 3) {
return evaluate(ec.getRowIndex(), ec.getColumnIndex(), args[0], args[1], args[2]);
}
return ErrorEval.VALUE_INVALID;
}
} }

Binary file not shown.