Return int on .0 floats
This commit is contained in:
@@ -117,6 +117,12 @@ class Expression(Node):
|
||||
ret = getattr(vala, operation)(valb)
|
||||
if ret is NotImplemented:
|
||||
ret = getattr(valb, operation)(vala)
|
||||
if oper in '+-*/':
|
||||
try:
|
||||
if int(ret) == ret:
|
||||
return int(ret)
|
||||
except ValueError:
|
||||
pass
|
||||
return ret
|
||||
|
||||
def expression(self):
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
margin-left: 1.7;
|
||||
}
|
||||
.span1 {
|
||||
width: 27.0;
|
||||
width: 27;
|
||||
}
|
||||
.span2 {
|
||||
width: 55.7;
|
||||
@@ -112,7 +112,7 @@
|
||||
width: 285.3;
|
||||
}
|
||||
.span11 {
|
||||
width: 314.0;
|
||||
width: 314;
|
||||
}
|
||||
.span12, .container {
|
||||
width: 342.7;
|
||||
@@ -142,7 +142,7 @@
|
||||
margin-left: 231.3;
|
||||
}
|
||||
.offset9 {
|
||||
margin-left: 260.0;
|
||||
margin-left: 260;
|
||||
}
|
||||
.offset10 {
|
||||
margin-left: 288.7;
|
||||
|
||||
6
lesscpy/test/css/grid.min.css
vendored
6
lesscpy/test/css/grid.min.css
vendored
@@ -25,7 +25,7 @@
|
||||
.offset11{margin-left:900px;}
|
||||
.row{margin-left:-1.7;}
|
||||
[class*="span"]{float:left;margin-left:1.7;}
|
||||
.span1{width:27.0;}
|
||||
.span1{width:27;}
|
||||
.span2{width:55.7;}
|
||||
.span3{width:84.4;}
|
||||
.span4{width:113.1;}
|
||||
@@ -35,7 +35,7 @@
|
||||
.span8{width:227.9;}
|
||||
.span9{width:256.6;}
|
||||
.span10{width:285.3;}
|
||||
.span11{width:314.0;}
|
||||
.span11{width:314;}
|
||||
.span12,.container{width:342.7;}
|
||||
.offset1{margin-left:30.4;}
|
||||
.offset2{margin-left:59.1;}
|
||||
@@ -45,6 +45,6 @@
|
||||
.offset6{margin-left:173.9;}
|
||||
.offset7{margin-left:202.6;}
|
||||
.offset8{margin-left:231.3;}
|
||||
.offset9{margin-left:260.0;}
|
||||
.offset9{margin-left:260;}
|
||||
.offset10{margin-left:288.7;}
|
||||
.offset11{margin-left:317.4;}
|
||||
|
||||
@@ -8,16 +8,16 @@ class TestExpression(unittest.TestCase):
|
||||
for test in [
|
||||
['0', '+', '0', '0'],
|
||||
['2', '+', '2', '4'],
|
||||
['2.0', '+', '2', '4.0'],
|
||||
['2', '+', '2.0', '4.0'],
|
||||
['2.0', '+', '2.0', '4.0'],
|
||||
[('2.0',), '+', '2.0', '4.0'],
|
||||
[('2.0',), '+', ('2.0',), '4.0'],
|
||||
['2.0', '+', '2', '4'],
|
||||
['2', '+', '2.0', '4'],
|
||||
['2.0', '+', '2.0', '4'],
|
||||
[('2.0',), '+', '2.0', '4'],
|
||||
[('2.0',), '+', ('2.0',), '4'],
|
||||
['0px', '+', '0', '0'],
|
||||
['2px', '+', '2', '4px'],
|
||||
['2.0px', '+', '2', '4.0px'],
|
||||
[('2px', ' '), '+', '2.0', '4.0px'],
|
||||
['2.0px', '+', '2.0', '4.0px'],
|
||||
['2.0px', '+', '2', '4px'],
|
||||
[('2px', ' '), '+', '2.0', '4px'],
|
||||
['2.0px', '+', '2.0', '4px'],
|
||||
]:
|
||||
e = Expression(test[:3])
|
||||
self.assertEqual(test[3], e.parse(None), str(test))
|
||||
@@ -26,19 +26,19 @@ class TestExpression(unittest.TestCase):
|
||||
for test in [
|
||||
['-0', '+', '0', '0'],
|
||||
['-2', '+', '-2', '-4'],
|
||||
['-2.0', '+', '-2', '-4.0'],
|
||||
['-2', '+', '-2.0', '-4.0'],
|
||||
['-2.0', '+', '-2.0', '-4.0'],
|
||||
['-2.0', '+', '-2', '-4'],
|
||||
['-2', '+', '-2.0', '-4'],
|
||||
['-2.0', '+', '-2.0', '-4'],
|
||||
['-0', '-', '0', '0'],
|
||||
['-2', '-', '-2', '0'],
|
||||
['-2.0', '-', '2', '-4.0'],
|
||||
['-2', '-', '-2.0', '0.0'],
|
||||
['2.0', '-', '-2.0', '4.0'],
|
||||
['-2.0', '-', '2', '-4'],
|
||||
['-2', '-', '-2.0', '0'],
|
||||
['2.0', '-', '-2.0', '4'],
|
||||
['-0px', '+', '0', '0'],
|
||||
['-2px', '+', '-2', '-4px'],
|
||||
['-2.0', '+', '-2px', '-4.0px'],
|
||||
['-2em', '+', '-2.0', '-4.0em'],
|
||||
['-2.0s', '+', '-2.0s', '-4.0s'],
|
||||
['-2.0', '+', '-2px', '-4px'],
|
||||
['-2em', '+', '-2.0', '-4em'],
|
||||
['-2.0s', '+', '-2.0s', '-4s'],
|
||||
]:
|
||||
e = Expression(test[:3])
|
||||
self.assertEqual(test[3], e.parse(None), str(test))
|
||||
|
||||
Reference in New Issue
Block a user