Lines 41-47
Link Here
|
41 |
import org.apache.poi.ss.formula.ptg.ErrPtg; |
41 |
import org.apache.poi.ss.formula.ptg.ErrPtg; |
42 |
import org.apache.poi.ss.formula.ptg.FuncPtg; |
42 |
import org.apache.poi.ss.formula.ptg.FuncPtg; |
43 |
import org.apache.poi.ss.formula.ptg.FuncVarPtg; |
43 |
import org.apache.poi.ss.formula.ptg.FuncVarPtg; |
|
|
44 |
import org.apache.poi.ss.formula.ptg.GreaterThanPtg; |
44 |
import org.apache.poi.ss.formula.ptg.IntPtg; |
45 |
import org.apache.poi.ss.formula.ptg.IntPtg; |
|
|
46 |
import org.apache.poi.ss.formula.ptg.IntersectionPtg; |
45 |
import org.apache.poi.ss.formula.ptg.MemAreaPtg; |
47 |
import org.apache.poi.ss.formula.ptg.MemAreaPtg; |
46 |
import org.apache.poi.ss.formula.ptg.MemFuncPtg; |
48 |
import org.apache.poi.ss.formula.ptg.MemFuncPtg; |
47 |
import org.apache.poi.ss.formula.ptg.MissingArgPtg; |
49 |
import org.apache.poi.ss.formula.ptg.MissingArgPtg; |
Lines 664-670
Link Here
|
664 |
assertEquals("IF(1<2,SUM(5,2,IF(3>2,SUM(A1:A2),6)),4)", formulaString); |
666 |
assertEquals("IF(1<2,SUM(5,2,IF(3>2,SUM(A1:A2),6)),4)", formulaString); |
665 |
} |
667 |
} |
666 |
public void testParserErrors() { |
668 |
public void testParserErrors() { |
667 |
parseExpectedException("1 2"); |
|
|
668 |
parseExpectedException(" 12 . 345 "); |
669 |
parseExpectedException(" 12 . 345 "); |
669 |
parseExpectedException("1 .23 "); |
670 |
parseExpectedException("1 .23 "); |
670 |
|
671 |
|
Lines 1017-1024
Link Here
|
1017 |
); |
1018 |
); |
1018 |
MemFuncPtg mf = (MemFuncPtg)ptgs[0]; |
1019 |
MemFuncPtg mf = (MemFuncPtg)ptgs[0]; |
1019 |
assertEquals(45, mf.getLenRefSubexpression()); |
1020 |
assertEquals(45, mf.getLenRefSubexpression()); |
|
|
1021 |
|
1022 |
// We don't check the type of the operands. |
1023 |
confirmTokenClasses("1,2", MemAreaPtg.class, IntPtg.class, IntPtg.class, UnionPtg.class); |
1020 |
} |
1024 |
} |
1021 |
|
1025 |
|
|
|
1026 |
public void testIntersection() { |
1027 |
String formula = "Sheet1!$B$2:$C$3 OFFSET(Sheet1!$E$2:$E$4, 1,Sheet1!$A$1) Sheet1!$D$6"; |
1028 |
HSSFWorkbook wb = new HSSFWorkbook(); |
1029 |
wb.createSheet("Sheet1"); |
1030 |
Ptg[] ptgs = FormulaParser.parse(formula, HSSFEvaluationWorkbook.create(wb), FormulaType.CELL, -1); |
1031 |
|
1032 |
confirmTokenClasses(ptgs, |
1033 |
// TODO - AttrPtg.class, // Excel prepends this |
1034 |
MemFuncPtg.class, |
1035 |
Area3DPtg.class, |
1036 |
Area3DPtg.class, |
1037 |
IntPtg.class, |
1038 |
Ref3DPtg.class, |
1039 |
FuncVarPtg.class, |
1040 |
IntersectionPtg.class, |
1041 |
Ref3DPtg.class, |
1042 |
IntersectionPtg.class |
1043 |
); |
1044 |
MemFuncPtg mf = (MemFuncPtg)ptgs[0]; |
1045 |
assertEquals(45, mf.getLenRefSubexpression()); |
1046 |
|
1047 |
// This used to be an error but now parses. Union has the same behaviour. |
1048 |
confirmTokenClasses("1 2", MemAreaPtg.class, IntPtg.class, IntPtg.class, IntersectionPtg.class); |
1049 |
} |
1050 |
|
1051 |
public void testComparisonInParen() { |
1052 |
confirmTokenClasses("(A1 > B2)", |
1053 |
RefPtg.class, |
1054 |
RefPtg.class, |
1055 |
GreaterThanPtg.class, |
1056 |
ParenthesisPtg.class |
1057 |
); |
1058 |
} |
1059 |
|
1060 |
public void testUnionInParen() { |
1061 |
confirmTokenClasses("(A1:B2,B2:C3)", |
1062 |
MemAreaPtg.class, |
1063 |
AreaPtg.class, |
1064 |
AreaPtg.class, |
1065 |
UnionPtg.class, |
1066 |
ParenthesisPtg.class |
1067 |
); |
1068 |
} |
1069 |
|
1070 |
public void testIntersectionInParen() { |
1071 |
confirmTokenClasses("(A1:B2 B2:C3)", |
1072 |
MemAreaPtg.class, |
1073 |
AreaPtg.class, |
1074 |
AreaPtg.class, |
1075 |
IntersectionPtg.class, |
1076 |
ParenthesisPtg.class |
1077 |
); |
1078 |
} |
1079 |
|
1022 |
public void testRange_bug46643() { |
1080 |
public void testRange_bug46643() { |
1023 |
String formula = "Sheet1!A1:Sheet1!B3"; |
1081 |
String formula = "Sheet1!A1:Sheet1!B3"; |
1024 |
HSSFWorkbook wb = new HSSFWorkbook(); |
1082 |
HSSFWorkbook wb = new HSSFWorkbook(); |