Warning, /webapps/ocs-webserver/library/lessphp/tests/inputs/math.less is written in an unsupported language. File is not indexed.
0001
0002 .unary {
0003 // all operators are parsable as unary operators, anything
0004 // but - throws an error right now though,
0005
0006 // this gives two numbers
0007 sub: 10 -5;
0008 // add: 10 +5; // error
0009 // div: 10 /5; // error
0010 // mul: 10 *5; // error
0011 }
0012
0013 .spaces {
0014 // we can make the parser do math by leaving out the
0015 // space after the first value, or putting spaces on both sides
0016
0017 sub1: 10-5;
0018 sub2: 10 - 5;
0019
0020 add1: 10+5;
0021 add2: 10 + 5;
0022
0023 // div: 10/5; // this wont work, read on
0024 div: 10 / 5;
0025
0026 mul1: 10*5;
0027 mul2: 10 * 5;
0028 }
0029
0030 // these properties have divison not in parenthases
0031 .supress-division {
0032 border-radius: 10px / 10px;
0033 border-radius: 10px/12px;
0034 border-radius: hello (10px/10px) world;
0035 @x: 10px;
0036 font: @x/30 sans-serif;
0037 font: 10px / 20px sans-serif;
0038 font: 10px/22px sans-serif;
0039 border-radius:0 15px 15px 15px / 0 50% 50% 50%;
0040 }
0041
0042
0043 .parens {
0044 // if you are unsure, then just wrap the expression in parentheses and it will
0045 // always evaluate.
0046
0047 // notice we no longer have unary operators, and these will evaluate
0048 sub: (10 -5);
0049 add: (10 +5);
0050 div1: (10 /5);
0051 div2: (10/5); // no longer interpreted as the shorthand
0052 mul: (10 *5);
0053 }
0054
0055 .keyword-names {
0056 // watch out when doing math with keywords, - is a valid keyword character
0057 @a: 100;
0058 @b: 25;
0059 @a-: "hello";
0060 height: @a-@b; // here we get "hello" 25, not 75
0061 }
0062
0063
0064 .negation {
0065 neg1: -(1px);
0066 neg2: 0-(1px);
0067
0068 @something: 10;
0069 neg3: -@something;
0070 }
0071
0072
0073 // and now here are the tests
0074
0075 .test {
0076 single1: (5);
0077 single2: 5+(5);
0078 single3: (5)+((5));
0079
0080 parens: (5 +(5)) -2;
0081 // parens: ((5 +(5)) -2); // FAILS - fixme
0082
0083 math1: (5 + 5)*(2 / 1);
0084 math2: (5+5)*(2/1);
0085
0086 complex1: 2 * (4 * (2 + (1 + 6))) - 1;
0087 complex2: ((2+3)*(2+3) / (9-4)) + 1;
0088 complex3: (2px + 4px) 1em 2px 2;
0089
0090 @var: (2 * 2);
0091 var1: (2 * @var) 4 4 (@var * 1px);
0092 var2: (@var * @var) * 6;
0093 var3: 4 * (5 + 5) / 2 - (@var * 2);
0094
0095 complex4: (7 * 7) + (8 * 8);
0096 }
0097
0098 .percents {
0099 p1: 100 * 10%;
0100 p2: 10% * 100;
0101 p3: 10% * 10%;
0102
0103 p4: 100px * 10%; // lessjs makes this px
0104 p5: 10% * 100px; // lessjs makes this %
0105
0106 p6: 20% + 10%;
0107 p7: 20% - 10%;
0108
0109 p8: 20% / 10%;
0110 }
0111
0112 .misc {
0113 x: 10px * 4em;
0114 y: 10 * 4em;
0115 }
0116
0117
0118 .cond {
0119 c1: 10 < 10;
0120 c2: 10 >= 10;
0121 }
0122