Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
9908f722
Commit
9908f722
authored
Oct 26, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for SUBTOTAL formula
parent
d5b0fbf2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
4 deletions
+47
-4
cell/.unit-tests/FormulaTests.js
cell/.unit-tests/FormulaTests.js
+43
-0
cell/model/FormulaObjects/mathematicFunctions.js
cell/model/FormulaObjects/mathematicFunctions.js
+4
-4
No files found.
cell/.unit-tests/FormulaTests.js
View file @
9908f722
...
@@ -9314,5 +9314,48 @@ $( function () {
...
@@ -9314,5 +9314,48 @@ $( function () {
});
});
test
(
"
Test:
\"
SUBTOTAL
\"
"
,
function
()
{
ws
.
getRange2
(
"
A102
"
).
setValue
(
"
120
"
);
ws
.
getRange2
(
"
A103
"
).
setValue
(
"
10
"
);
ws
.
getRange2
(
"
A104
"
).
setValue
(
"
150
"
);
ws
.
getRange2
(
"
A105
"
).
setValue
(
"
23
"
);
oParser
=
new
parserFormula
(
"
SUBTOTAL(1,A102:A105)
"
,
"
A2
"
,
ws
);
ok
(
oParser
.
parse
(),
"
SUBTOTAL(1,A102:A105)
"
);
strictEqual
(
oParser
.
calculate
().
getValue
().
toFixed
(
2
)
-
0
,
75.75
,
"
SUBTOTAL(1,A102:A105)
"
);
oParser
=
new
parserFormula
(
"
SUBTOTAL(2,A102:A105)
"
,
"
A2
"
,
ws
);
ok
(
oParser
.
parse
(),
"
SUBTOTAL(2,A102:A105)
"
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
4
,
"
SUBTOTAL(2,A102:A105)
"
);
oParser
=
new
parserFormula
(
"
SUBTOTAL(3,A102:A105)
"
,
"
A2
"
,
ws
);
ok
(
oParser
.
parse
(),
"
SUBTOTAL(3,A102:A105)
"
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
4
,
"
SUBTOTAL(3,A102:A105)
"
);
oParser
=
new
parserFormula
(
"
SUBTOTAL(4,A102:A105)
"
,
"
A2
"
,
ws
);
ok
(
oParser
.
parse
(),
"
SUBTOTAL(4,A102:A105)
"
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
150
,
"
SUBTOTAL(4,A102:A105)
"
);
oParser
=
new
parserFormula
(
"
SUBTOTAL(5,A102:A105)
"
,
"
A2
"
,
ws
);
ok
(
oParser
.
parse
(),
"
SUBTOTAL(5,A102:A105)
"
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
10
,
"
SUBTOTAL(5,A102:A105)
"
);
oParser
=
new
parserFormula
(
"
SUBTOTAL(6,A102:A105)
"
,
"
A2
"
,
ws
);
ok
(
oParser
.
parse
(),
"
SUBTOTAL(6,A102:A105)
"
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
4140000
,
"
SUBTOTAL(6,A102:A105)
"
);
oParser
=
new
parserFormula
(
"
SUBTOTAL(7,A102:A105)
"
,
"
A2
"
,
ws
);
ok
(
oParser
.
parse
(),
"
SUBTOTAL(7,A102:A105)
"
);
strictEqual
(
oParser
.
calculate
().
getValue
().
toFixed
(
8
)
-
0
,
69.70592992
,
"
SUBTOTAL(7,A102:A105)
"
);
oParser
=
new
parserFormula
(
"
SUBTOTAL(8,A102:A105)
"
,
"
A2
"
,
ws
);
ok
(
oParser
.
parse
(),
"
SUBTOTAL(8,A102:A105)
"
);
strictEqual
(
oParser
.
calculate
().
getValue
().
toFixed
(
8
)
-
0
,
60.36710611
,
"
SUBTOTAL(8,A102:A105)
"
);
oParser
=
new
parserFormula
(
"
SUBTOTAL(9,A102:A105)
"
,
"
A2
"
,
ws
);
ok
(
oParser
.
parse
(),
"
SUBTOTAL(9,A102:A105)
"
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
303
,
"
SUBTOTAL(9,A102:A105)
"
);
}
);
wb
.
dependencyFormulas
.
unlockRecal
();
wb
.
dependencyFormulas
.
unlockRecal
();
}
);
}
);
cell/model/FormulaObjects/mathematicFunctions.js
View file @
9908f722
...
@@ -4178,22 +4178,22 @@
...
@@ -4178,22 +4178,22 @@
case
cSubTotalFunctionType
.
excludes
.
COUNT
:
case
cSubTotalFunctionType
.
excludes
.
COUNT
:
exclude
=
true
;
exclude
=
true
;
case
cSubTotalFunctionType
.
includes
.
COUNT
:
case
cSubTotalFunctionType
.
includes
.
COUNT
:
f
=
AscCommonExcel
.
prototype
;
f
=
AscCommonExcel
.
cCOUNT
.
prototype
;
break
;
break
;
case
cSubTotalFunctionType
.
excludes
.
COUNTA
:
case
cSubTotalFunctionType
.
excludes
.
COUNTA
:
exclude
=
true
;
exclude
=
true
;
case
cSubTotalFunctionType
.
includes
.
COUNTA
:
case
cSubTotalFunctionType
.
includes
.
COUNTA
:
f
=
AscCommonExcel
.
prototype
;
f
=
AscCommonExcel
.
cCOUNTA
.
prototype
;
break
;
break
;
case
cSubTotalFunctionType
.
excludes
.
MAX
:
case
cSubTotalFunctionType
.
excludes
.
MAX
:
exclude
=
true
;
exclude
=
true
;
case
cSubTotalFunctionType
.
includes
.
MAX
:
case
cSubTotalFunctionType
.
includes
.
MAX
:
f
=
AscCommonExcel
.
prototype
;
f
=
AscCommonExcel
.
cMAX
.
prototype
;
break
;
break
;
case
cSubTotalFunctionType
.
excludes
.
MIN
:
case
cSubTotalFunctionType
.
excludes
.
MIN
:
exclude
=
true
;
exclude
=
true
;
case
cSubTotalFunctionType
.
includes
.
MIN
:
case
cSubTotalFunctionType
.
includes
.
MIN
:
f
=
AscCommonExcel
.
prototype
;
f
=
AscCommonExcel
.
cMIN
.
prototype
;
break
;
break
;
case
cSubTotalFunctionType
.
excludes
.
PRODUCT
:
case
cSubTotalFunctionType
.
excludes
.
PRODUCT
:
exclude
=
true
;
exclude
=
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment