Skip to content

Commit

Permalink
Fix "calculates with negative values" by fixing .sort()
Browse files Browse the repository at this point in the history
  • Loading branch information
artginzburg committed May 12, 2023
1 parent 9b2df2b commit bb274f4
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 72 deletions.
51 changes: 26 additions & 25 deletions coverage/clover.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1683907612323" clover="3.2.0">
<project timestamp="1683907612323" name="All files">
<metrics statements="36" coveredstatements="36" conditionals="9" coveredconditionals="9" methods="13" coveredmethods="13" elements="58" coveredelements="58" complexity="0" loc="36" ncloc="36" packages="1" files="2" classes="2"/>
<coverage generated="1683908636004" clover="3.2.0">
<project timestamp="1683908636004" name="All files">
<metrics statements="37" coveredstatements="37" conditionals="9" coveredconditionals="9" methods="14" coveredmethods="14" elements="60" coveredelements="60" complexity="0" loc="37" ncloc="37" packages="1" files="2" classes="2"/>
<file name="index.ts" path="/Users/artginzburg/css-clamper/src/index.ts">
<metrics statements="15" coveredstatements="15" conditionals="4" coveredconditionals="4" methods="5" coveredmethods="5"/>
<metrics statements="16" coveredstatements="16" conditionals="4" coveredconditionals="4" methods="6" coveredmethods="6"/>
<line num="1" count="2" type="stmt"/>
<line num="19" count="2" type="stmt"/>
<line num="23" count="21" type="cond" truecount="1" falsecount="0"/>
<line num="25" count="21" type="cond" truecount="1" falsecount="0"/>
<line num="27" count="11" type="stmt"/>
<line num="34" count="11" type="stmt"/>
<line num="36" count="11" type="stmt"/>
<line num="41" count="11" type="stmt"/>
<line num="44" count="22" type="stmt"/>
<line num="46" count="11" type="stmt"/>
<line num="48" count="11" type="stmt"/>
<line num="60" count="11" type="stmt"/>
<line num="23" count="25" type="cond" truecount="1" falsecount="0"/>
<line num="25" count="25" type="cond" truecount="1" falsecount="0"/>
<line num="27" count="13" type="stmt"/>
<line num="34" count="13" type="stmt"/>
<line num="36" count="13" type="stmt"/>
<line num="41" count="13" type="stmt"/>
<line num="43" count="13" type="stmt"/>
<line num="44" count="26" type="stmt"/>
<line num="46" count="13" type="stmt"/>
<line num="48" count="13" type="stmt"/>
<line num="60" count="13" type="stmt"/>
<line num="70" count="2" type="stmt"/>
<line num="71" count="1" type="stmt"/>
<line num="75" count="1" type="stmt"/>
Expand All @@ -25,24 +26,24 @@
<line num="1" count="2" type="stmt"/>
<line num="3" count="2" type="stmt"/>
<line num="4" count="2" type="stmt"/>
<line num="7" count="78" type="stmt"/>
<line num="7" count="90" type="stmt"/>
<line num="10" count="2" type="stmt"/>
<line num="11" count="81" type="stmt"/>
<line num="12" count="81" type="cond" truecount="1" falsecount="0"/>
<line num="11" count="93" type="stmt"/>
<line num="12" count="93" type="cond" truecount="1" falsecount="0"/>
<line num="13" count="4" type="stmt"/>
<line num="15" count="77" type="stmt"/>
<line num="16" count="77" type="stmt"/>
<line num="17" count="77" type="stmt"/>
<line num="15" count="89" type="stmt"/>
<line num="16" count="89" type="stmt"/>
<line num="17" count="89" type="stmt"/>
<line num="20" count="2" type="stmt"/>
<line num="21" count="29" type="stmt"/>
<line num="21" count="35" type="stmt"/>
<line num="24" count="13" type="stmt"/>
<line num="27" count="2" type="stmt"/>
<line num="28" count="22" type="stmt"/>
<line num="28" count="26" type="stmt"/>
<line num="32" count="2" type="stmt"/>
<line num="33" count="56" type="stmt"/>
<line num="44" count="78" type="stmt"/>
<line num="33" count="64" type="stmt"/>
<line num="44" count="90" type="stmt"/>
<line num="53" count="2" type="stmt"/>
<line num="54" count="11" type="stmt"/>
<line num="54" count="13" type="stmt"/>
</file>
</project>
</coverage>
4 changes: 2 additions & 2 deletions coverage/coverage-final.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{"/Users/artginzburg/css-clamper/src/index.ts": {"path":"/Users/artginzburg/css-clamper/src/index.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":null}},"1":{"start":{"line":23,"column":2},"end":{"line":23,"column":null}},"2":{"start":{"line":25,"column":2},"end":{"line":25,"column":null}},"3":{"start":{"line":27,"column":65},"end":{"line":32,"column":13}},"4":{"start":{"line":27,"column":19},"end":{"line":27,"column":21}},"5":{"start":{"line":27,"column":31},"end":{"line":27,"column":33}},"6":{"start":{"line":27,"column":46},"end":{"line":27,"column":48}},"7":{"start":{"line":27,"column":61},"end":{"line":27,"column":65}},"8":{"start":{"line":34,"column":23},"end":{"line":34,"column":82}},"9":{"start":{"line":36,"column":19},"end":{"line":37,"column":null}},"10":{"start":{"line":41,"column":45},"end":{"line":44,"column":41}},"11":{"start":{"line":44,"column":19},"end":{"line":44,"column":41}},"12":{"start":{"line":41,"column":24},"end":{"line":41,"column":26}},"13":{"start":{"line":41,"column":41},"end":{"line":41,"column":45}},"14":{"start":{"line":46,"column":29},"end":{"line":46,"column":86}},"15":{"start":{"line":48,"column":2},"end":{"line":52,"column":4}},"16":{"start":{"line":19,"column":0},"end":{"line":19,"column":16}},"17":{"start":{"line":60,"column":2},"end":{"line":60,"column":44}},"18":{"start":{"line":71,"column":2},"end":{"line":76,"column":4}},"19":{"start":{"line":75,"column":4},"end":{"line":75,"column":66}},"20":{"start":{"line":70,"column":0},"end":{"line":70,"column":16}}},"fnMap":{"0":{"name":"clampify","decl":{"start":{"line":19,"column":16},"end":{"line":19,"column":24}},"loc":{"start":{"line":25,"column":43},"end":{"line":53,"column":1}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":44,"column":9},"end":{"line":44,"column":10}},"loc":{"start":{"line":44,"column":14},"end":{"line":44,"column":22}}},"2":{"name":"shiftDecimalPointRightByTwo","decl":{"start":{"line":59,"column":9},"end":{"line":59,"column":36}},"loc":{"start":{"line":59,"column":48},"end":{"line":61,"column":1}}},"3":{"name":"createClamper","decl":{"start":{"line":70,"column":16},"end":{"line":70,"column":29}},"loc":{"start":{"line":70,"column":92},"end":{"line":77,"column":1}}},"4":{"name":"clamper","decl":{"start":{"line":71,"column":18},"end":{"line":71,"column":25}},"loc":{"start":{"line":73,"column":44},"end":{"line":76,"column":3}}}},"branchMap":{"0":{"loc":{"start":{"line":23,"column":2},"end":{"line":23,"column":null}},"type":"if","locations":[{"start":{"line":23,"column":2},"end":{"line":23,"column":null}}]},"1":{"loc":{"start":{"line":25,"column":2},"end":{"line":25,"column":null}},"type":"if","locations":[{"start":{"line":25,"column":2},"end":{"line":25,"column":null}}]},"2":{"loc":{"start":{"line":50,"column":7},"end":{"line":50,"column":53}},"type":"cond-expr","locations":[{"start":{"line":50,"column":19},"end":{"line":50,"column":48}},{"start":{"line":50,"column":51},"end":{"line":50,"column":53}}]}},"s":{"0":2,"1":21,"2":21,"3":11,"4":11,"5":11,"6":11,"7":11,"8":11,"9":11,"10":11,"11":22,"12":11,"13":11,"14":11,"15":11,"16":2,"17":11,"18":1,"19":1,"20":2},"f":{"0":11,"1":22,"2":11,"3":1,"4":1},"b":{"0":[10],"1":[10],"2":[8,3]}}
,"/Users/artginzburg/css-clamper/src/internals.ts": {"path":"/Users/artginzburg/css-clamper/src/internals.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}},"1":{"start":{"line":3,"column":24},"end":{"line":3,"column":26}},"2":{"start":{"line":4,"column":13},"end":{"line":4,"column":39}},"3":{"start":{"line":7,"column":2},"end":{"line":7,"column":31}},"4":{"start":{"line":11,"column":18},"end":{"line":11,"column":52}},"5":{"start":{"line":12,"column":2},"end":{"line":14,"column":null}},"6":{"start":{"line":13,"column":4},"end":{"line":13,"column":39}},"7":{"start":{"line":15,"column":15},"end":{"line":15,"column":29}},"8":{"start":{"line":16,"column":14},"end":{"line":16,"column":36}},"9":{"start":{"line":17,"column":2},"end":{"line":17,"column":23}},"10":{"start":{"line":10,"column":0},"end":{"line":10,"column":16}},"11":{"start":{"line":21,"column":2},"end":{"line":21,"column":31}},"12":{"start":{"line":20,"column":0},"end":{"line":20,"column":16}},"13":{"start":{"line":24,"column":2},"end":{"line":24,"column":31}},"14":{"start":{"line":28,"column":2},"end":{"line":30,"column":4}},"15":{"start":{"line":27,"column":0},"end":{"line":27,"column":16}},"16":{"start":{"line":33,"column":2},"end":{"line":35,"column":4}},"17":{"start":{"line":32,"column":0},"end":{"line":32,"column":16}},"18":{"start":{"line":44,"column":2},"end":{"line":44,"column":47}},"19":{"start":{"line":54,"column":2},"end":{"line":54,"column":56}},"20":{"start":{"line":53,"column":0},"end":{"line":53,"column":16}}},"fnMap":{"0":{"name":"isRem","decl":{"start":{"line":6,"column":9},"end":{"line":6,"column":14}},"loc":{"start":{"line":6,"column":28},"end":{"line":8,"column":1}}},"1":{"name":"parseUnitValue","decl":{"start":{"line":10,"column":16},"end":{"line":10,"column":30}},"loc":{"start":{"line":10,"column":44},"end":{"line":18,"column":1}}},"2":{"name":"numPxToRem","decl":{"start":{"line":20,"column":16},"end":{"line":20,"column":26}},"loc":{"start":{"line":20,"column":38},"end":{"line":22,"column":1}}},"3":{"name":"numRemToPx","decl":{"start":{"line":23,"column":9},"end":{"line":23,"column":19}},"loc":{"start":{"line":23,"column":31},"end":{"line":25,"column":1}}},"4":{"name":"toRem","decl":{"start":{"line":27,"column":16},"end":{"line":27,"column":21}},"loc":{"start":{"line":27,"column":35},"end":{"line":31,"column":1}}},"5":{"name":"toPx","decl":{"start":{"line":32,"column":16},"end":{"line":32,"column":20}},"loc":{"start":{"line":32,"column":34},"end":{"line":36,"column":1}}},"6":{"name":"toFixedNumberDefault","decl":{"start":{"line":43,"column":9},"end":{"line":43,"column":29}},"loc":{"start":{"line":43,"column":43},"end":{"line":45,"column":1}}},"7":{"name":"buildCssClamp","decl":{"start":{"line":53,"column":16},"end":{"line":53,"column":29}},"loc":{"start":{"line":53,"column":90},"end":{"line":55,"column":1}}}},"branchMap":{"0":{"loc":{"start":{"line":12,"column":2},"end":{"line":14,"column":null}},"type":"if","locations":[{"start":{"line":12,"column":2},"end":{"line":14,"column":null}}]},"1":{"loc":{"start":{"line":29,"column":4},"end":{"line":29,"column":84}},"type":"cond-expr","locations":[{"start":{"line":29,"column":19},"end":{"line":29,"column":44}},{"start":{"line":29,"column":47},"end":{"line":29,"column":84}}]},"2":{"loc":{"start":{"line":34,"column":4},"end":{"line":34,"column":84}},"type":"cond-expr","locations":[{"start":{"line":34,"column":19},"end":{"line":34,"column":56}},{"start":{"line":34,"column":59},"end":{"line":34,"column":84}}]}},"s":{"0":2,"1":2,"2":2,"3":78,"4":81,"5":81,"6":4,"7":77,"8":77,"9":77,"10":2,"11":29,"12":2,"13":13,"14":22,"15":2,"16":56,"17":2,"18":78,"19":11,"20":2},"f":{"0":78,"1":81,"2":29,"3":13,"4":22,"5":56,"6":78,"7":11},"b":{"0":[4],"1":[4,18],"2":[13,43]}}
{"/Users/artginzburg/css-clamper/src/index.ts": {"path":"/Users/artginzburg/css-clamper/src/index.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":null}},"1":{"start":{"line":23,"column":2},"end":{"line":23,"column":null}},"2":{"start":{"line":25,"column":2},"end":{"line":25,"column":null}},"3":{"start":{"line":27,"column":65},"end":{"line":32,"column":13}},"4":{"start":{"line":27,"column":19},"end":{"line":27,"column":21}},"5":{"start":{"line":27,"column":31},"end":{"line":27,"column":33}},"6":{"start":{"line":27,"column":46},"end":{"line":27,"column":48}},"7":{"start":{"line":27,"column":61},"end":{"line":27,"column":65}},"8":{"start":{"line":34,"column":23},"end":{"line":34,"column":82}},"9":{"start":{"line":36,"column":19},"end":{"line":37,"column":null}},"10":{"start":{"line":41,"column":45},"end":{"line":44,"column":41}},"11":{"start":{"line":43,"column":20},"end":{"line":43,"column":26}},"12":{"start":{"line":44,"column":19},"end":{"line":44,"column":41}},"13":{"start":{"line":41,"column":24},"end":{"line":41,"column":26}},"14":{"start":{"line":41,"column":41},"end":{"line":41,"column":45}},"15":{"start":{"line":46,"column":29},"end":{"line":46,"column":86}},"16":{"start":{"line":48,"column":2},"end":{"line":52,"column":4}},"17":{"start":{"line":19,"column":0},"end":{"line":19,"column":16}},"18":{"start":{"line":60,"column":2},"end":{"line":60,"column":44}},"19":{"start":{"line":71,"column":2},"end":{"line":76,"column":4}},"20":{"start":{"line":75,"column":4},"end":{"line":75,"column":66}},"21":{"start":{"line":70,"column":0},"end":{"line":70,"column":16}}},"fnMap":{"0":{"name":"clampify","decl":{"start":{"line":19,"column":16},"end":{"line":19,"column":24}},"loc":{"start":{"line":25,"column":43},"end":{"line":53,"column":1}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":43,"column":10},"end":{"line":43,"column":11}},"loc":{"start":{"line":43,"column":15},"end":{"line":43,"column":21}}},"2":{"name":"(anonymous_2)","decl":{"start":{"line":44,"column":9},"end":{"line":44,"column":10}},"loc":{"start":{"line":44,"column":14},"end":{"line":44,"column":22}}},"3":{"name":"shiftDecimalPointRightByTwo","decl":{"start":{"line":59,"column":9},"end":{"line":59,"column":36}},"loc":{"start":{"line":59,"column":48},"end":{"line":61,"column":1}}},"4":{"name":"createClamper","decl":{"start":{"line":70,"column":16},"end":{"line":70,"column":29}},"loc":{"start":{"line":70,"column":92},"end":{"line":77,"column":1}}},"5":{"name":"clamper","decl":{"start":{"line":71,"column":18},"end":{"line":71,"column":25}},"loc":{"start":{"line":73,"column":44},"end":{"line":76,"column":3}}}},"branchMap":{"0":{"loc":{"start":{"line":23,"column":2},"end":{"line":23,"column":null}},"type":"if","locations":[{"start":{"line":23,"column":2},"end":{"line":23,"column":null}}]},"1":{"loc":{"start":{"line":25,"column":2},"end":{"line":25,"column":null}},"type":"if","locations":[{"start":{"line":25,"column":2},"end":{"line":25,"column":null}}]},"2":{"loc":{"start":{"line":50,"column":7},"end":{"line":50,"column":53}},"type":"cond-expr","locations":[{"start":{"line":50,"column":19},"end":{"line":50,"column":48}},{"start":{"line":50,"column":51},"end":{"line":50,"column":53}}]}},"s":{"0":2,"1":25,"2":25,"3":13,"4":13,"5":13,"6":13,"7":13,"8":13,"9":13,"10":13,"11":13,"12":26,"13":13,"14":13,"15":13,"16":13,"17":2,"18":13,"19":1,"20":1,"21":2},"f":{"0":13,"1":13,"2":26,"3":13,"4":1,"5":1},"b":{"0":[12],"1":[12],"2":[10,3]}}
,"/Users/artginzburg/css-clamper/src/internals.ts": {"path":"/Users/artginzburg/css-clamper/src/internals.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":35}},"1":{"start":{"line":3,"column":24},"end":{"line":3,"column":26}},"2":{"start":{"line":4,"column":13},"end":{"line":4,"column":39}},"3":{"start":{"line":7,"column":2},"end":{"line":7,"column":31}},"4":{"start":{"line":11,"column":18},"end":{"line":11,"column":52}},"5":{"start":{"line":12,"column":2},"end":{"line":14,"column":null}},"6":{"start":{"line":13,"column":4},"end":{"line":13,"column":39}},"7":{"start":{"line":15,"column":15},"end":{"line":15,"column":29}},"8":{"start":{"line":16,"column":14},"end":{"line":16,"column":36}},"9":{"start":{"line":17,"column":2},"end":{"line":17,"column":23}},"10":{"start":{"line":10,"column":0},"end":{"line":10,"column":16}},"11":{"start":{"line":21,"column":2},"end":{"line":21,"column":31}},"12":{"start":{"line":20,"column":0},"end":{"line":20,"column":16}},"13":{"start":{"line":24,"column":2},"end":{"line":24,"column":31}},"14":{"start":{"line":28,"column":2},"end":{"line":30,"column":4}},"15":{"start":{"line":27,"column":0},"end":{"line":27,"column":16}},"16":{"start":{"line":33,"column":2},"end":{"line":35,"column":4}},"17":{"start":{"line":32,"column":0},"end":{"line":32,"column":16}},"18":{"start":{"line":44,"column":2},"end":{"line":44,"column":47}},"19":{"start":{"line":54,"column":2},"end":{"line":54,"column":56}},"20":{"start":{"line":53,"column":0},"end":{"line":53,"column":16}}},"fnMap":{"0":{"name":"isRem","decl":{"start":{"line":6,"column":9},"end":{"line":6,"column":14}},"loc":{"start":{"line":6,"column":28},"end":{"line":8,"column":1}}},"1":{"name":"parseUnitValue","decl":{"start":{"line":10,"column":16},"end":{"line":10,"column":30}},"loc":{"start":{"line":10,"column":44},"end":{"line":18,"column":1}}},"2":{"name":"numPxToRem","decl":{"start":{"line":20,"column":16},"end":{"line":20,"column":26}},"loc":{"start":{"line":20,"column":38},"end":{"line":22,"column":1}}},"3":{"name":"numRemToPx","decl":{"start":{"line":23,"column":9},"end":{"line":23,"column":19}},"loc":{"start":{"line":23,"column":31},"end":{"line":25,"column":1}}},"4":{"name":"toRem","decl":{"start":{"line":27,"column":16},"end":{"line":27,"column":21}},"loc":{"start":{"line":27,"column":35},"end":{"line":31,"column":1}}},"5":{"name":"toPx","decl":{"start":{"line":32,"column":16},"end":{"line":32,"column":20}},"loc":{"start":{"line":32,"column":34},"end":{"line":36,"column":1}}},"6":{"name":"toFixedNumberDefault","decl":{"start":{"line":43,"column":9},"end":{"line":43,"column":29}},"loc":{"start":{"line":43,"column":43},"end":{"line":45,"column":1}}},"7":{"name":"buildCssClamp","decl":{"start":{"line":53,"column":16},"end":{"line":53,"column":29}},"loc":{"start":{"line":53,"column":90},"end":{"line":55,"column":1}}}},"branchMap":{"0":{"loc":{"start":{"line":12,"column":2},"end":{"line":14,"column":null}},"type":"if","locations":[{"start":{"line":12,"column":2},"end":{"line":14,"column":null}}]},"1":{"loc":{"start":{"line":29,"column":4},"end":{"line":29,"column":84}},"type":"cond-expr","locations":[{"start":{"line":29,"column":19},"end":{"line":29,"column":44}},{"start":{"line":29,"column":47},"end":{"line":29,"column":84}}]},"2":{"loc":{"start":{"line":34,"column":4},"end":{"line":34,"column":84}},"type":"cond-expr","locations":[{"start":{"line":34,"column":19},"end":{"line":34,"column":56}},{"start":{"line":34,"column":59},"end":{"line":34,"column":84}}]}},"s":{"0":2,"1":2,"2":2,"3":90,"4":93,"5":93,"6":4,"7":89,"8":89,"9":89,"10":2,"11":35,"12":2,"13":13,"14":26,"15":2,"16":64,"17":2,"18":90,"19":13,"20":2},"f":{"0":90,"1":93,"2":35,"3":13,"4":26,"5":64,"6":90,"7":13},"b":{"0":[4],"1":[4,22],"2":[13,51]}}
}
4 changes: 2 additions & 2 deletions coverage/coverage-summary.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{"total": {"lines":{"total":36,"covered":36,"skipped":0,"pct":100},"statements":{"total":42,"covered":42,"skipped":0,"pct":100},"functions":{"total":13,"covered":13,"skipped":0,"pct":100},"branches":{"total":9,"covered":9,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}}
,"/Users/artginzburg/css-clamper/src/index.ts": {"lines":{"total":15,"covered":15,"skipped":0,"pct":100},"functions":{"total":5,"covered":5,"skipped":0,"pct":100},"statements":{"total":21,"covered":21,"skipped":0,"pct":100},"branches":{"total":4,"covered":4,"skipped":0,"pct":100}}
{"total": {"lines":{"total":37,"covered":37,"skipped":0,"pct":100},"statements":{"total":43,"covered":43,"skipped":0,"pct":100},"functions":{"total":14,"covered":14,"skipped":0,"pct":100},"branches":{"total":9,"covered":9,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}}
,"/Users/artginzburg/css-clamper/src/index.ts": {"lines":{"total":16,"covered":16,"skipped":0,"pct":100},"functions":{"total":6,"covered":6,"skipped":0,"pct":100},"statements":{"total":22,"covered":22,"skipped":0,"pct":100},"branches":{"total":4,"covered":4,"skipped":0,"pct":100}}
,"/Users/artginzburg/css-clamper/src/internals.ts": {"lines":{"total":21,"covered":21,"skipped":0,"pct":100},"functions":{"total":8,"covered":8,"skipped":0,"pct":100},"statements":{"total":21,"covered":21,"skipped":0,"pct":100},"branches":{"total":5,"covered":5,"skipped":0,"pct":100}}
}
Loading

0 comments on commit bb274f4

Please sign in to comment.