less 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +4 -0
  3. data/Gemfile +1 -1
  4. data/less.gemspec +1 -1
  5. data/lib/less/defaults.rb +3 -3
  6. data/lib/less/java_script/v8_context.rb +1 -1
  7. data/lib/less/js/.gitattributes +3 -2
  8. data/lib/less/js/.gitignore +18 -2
  9. data/lib/less/js/.jshintrc +11 -0
  10. data/lib/less/js/CHANGELOG.md +87 -2
  11. data/lib/less/js/CONTRIBUTING.md +4 -3
  12. data/lib/less/js/Gruntfile.js +290 -0
  13. data/lib/less/js/README.md +342 -12
  14. data/lib/less/js/benchmark/benchmark.less +194 -194
  15. data/lib/less/js/benchmark/less-benchmark.js +9 -10
  16. data/lib/less/js/bin/lessc +154 -12
  17. data/lib/less/js/bower.json +18 -0
  18. data/lib/less/js/build.gradle +347 -0
  19. data/lib/less/js/build/README.md +350 -0
  20. data/lib/less/js/build/browser-header.js +4 -0
  21. data/lib/less/js/build/build.yml +160 -0
  22. data/lib/less/js/build/require-rhino.js +7 -2
  23. data/lib/less/js/build/rhino-header.js +4 -0
  24. data/lib/less/js/build/rhino-modules.js +131 -0
  25. data/lib/less/js/build/tasks/.gitkeep +1 -0
  26. data/lib/less/js/dist/less-1.5.0.js +6914 -0
  27. data/lib/less/js/dist/less-1.5.0.min.js +13 -0
  28. data/lib/less/js/dist/less-1.5.1.js +6941 -0
  29. data/lib/less/js/dist/less-1.5.1.min.js +13 -0
  30. data/lib/less/js/dist/less-1.6.0.js +7485 -0
  31. data/lib/less/js/dist/less-1.6.0.min.js +16 -0
  32. data/lib/less/js/dist/less-1.6.1.js +7513 -0
  33. data/lib/less/js/dist/less-1.6.1.min.js +16 -0
  34. data/lib/less/js/dist/less-1.6.2.js +7624 -0
  35. data/lib/less/js/dist/less-1.6.2.min.js +16 -0
  36. data/lib/less/js/dist/less-rhino-1.5.1.js +6831 -0
  37. data/lib/less/js/dist/less-rhino-1.6.2.js +9017 -0
  38. data/lib/less/js/dist/lessc-rhino-1.6.2.js +449 -0
  39. data/lib/less/js/gradle/wrapper/gradle-wrapper.jar +0 -0
  40. data/lib/less/js/gradle/wrapper/gradle-wrapper.properties +6 -0
  41. data/lib/less/js/gradlew +164 -0
  42. data/lib/less/js/gradlew.bat +90 -0
  43. data/lib/less/js/lib/less/browser.js +482 -367
  44. data/lib/less/js/lib/less/colors.js +0 -1
  45. data/lib/less/js/lib/less/encoder.js +4 -0
  46. data/lib/less/js/lib/less/env.js +50 -19
  47. data/lib/less/js/lib/less/extend-visitor.js +66 -41
  48. data/lib/less/js/lib/less/functions.js +309 -104
  49. data/lib/less/js/lib/less/import-visitor.js +21 -10
  50. data/lib/less/js/lib/less/index.js +90 -68
  51. data/lib/less/js/lib/less/join-selector-visitor.js +11 -4
  52. data/lib/less/js/lib/less/lessc_helper.js +56 -45
  53. data/lib/less/js/lib/less/parser.js +830 -460
  54. data/lib/less/js/lib/less/rhino.js +380 -58
  55. data/lib/less/js/lib/less/source-map-output.js +141 -0
  56. data/lib/less/js/lib/less/to-css-visitor.js +215 -0
  57. data/lib/less/js/lib/less/tree.js +57 -5
  58. data/lib/less/js/lib/less/tree/alpha.js +13 -5
  59. data/lib/less/js/lib/less/tree/anonymous.js +11 -5
  60. data/lib/less/js/lib/less/tree/assignment.js +11 -5
  61. data/lib/less/js/lib/less/tree/call.js +19 -8
  62. data/lib/less/js/lib/less/tree/color.js +59 -36
  63. data/lib/less/js/lib/less/tree/comment.js +17 -4
  64. data/lib/less/js/lib/less/tree/condition.js +3 -3
  65. data/lib/less/js/lib/less/tree/dimension.js +161 -153
  66. data/lib/less/js/lib/less/tree/directive.js +39 -18
  67. data/lib/less/js/lib/less/tree/element.js +41 -18
  68. data/lib/less/js/lib/less/tree/expression.js +11 -5
  69. data/lib/less/js/lib/less/tree/extend.js +11 -1
  70. data/lib/less/js/lib/less/tree/import.js +34 -20
  71. data/lib/less/js/lib/less/tree/javascript.js +16 -10
  72. data/lib/less/js/lib/less/tree/keyword.js +5 -2
  73. data/lib/less/js/lib/less/tree/media.js +39 -22
  74. data/lib/less/js/lib/less/tree/mixin.js +135 -56
  75. data/lib/less/js/lib/less/tree/negative.js +4 -2
  76. data/lib/less/js/lib/less/tree/operation.js +17 -12
  77. data/lib/less/js/lib/less/tree/paren.js +5 -2
  78. data/lib/less/js/lib/less/tree/quoted.js +9 -6
  79. data/lib/less/js/lib/less/tree/rule.js +39 -21
  80. data/lib/less/js/lib/less/tree/ruleset.js +229 -145
  81. data/lib/less/js/lib/less/tree/selector.js +101 -34
  82. data/lib/less/js/lib/less/tree/unicode-descriptor.js +4 -3
  83. data/lib/less/js/lib/less/tree/url.js +33 -11
  84. data/lib/less/js/lib/less/tree/value.js +13 -6
  85. data/lib/less/js/lib/less/tree/variable.js +13 -8
  86. data/lib/less/js/lib/less/visitor.js +117 -25
  87. data/lib/less/js/lib/source-map/source-map-0.1.31.js +1933 -0
  88. data/lib/less/js/lib/source-map/source-map-footer.js +4 -0
  89. data/lib/less/js/lib/source-map/source-map-header.js +3 -0
  90. data/lib/less/js/package.json +30 -15
  91. data/lib/less/js/test/browser/common.js +131 -56
  92. data/lib/less/js/test/browser/css/global-vars/simple.css +3 -0
  93. data/lib/less/js/test/browser/css/modify-vars/simple.css +8 -0
  94. data/lib/less/js/test/browser/css/relative-urls/urls.css +8 -9
  95. data/lib/less/js/test/browser/css/rootpath-relative/urls.css +0 -1
  96. data/lib/less/js/test/browser/css/rootpath/urls.css +0 -1
  97. data/lib/less/js/test/browser/css/urls.css +18 -14
  98. data/lib/less/js/test/browser/es5.js +27 -0
  99. data/lib/less/js/test/{less/errors/color-operation-error.less → browser/less/console-errors/test-error.less} +0 -0
  100. data/lib/less/js/test/browser/less/console-errors/test-error.txt +2 -0
  101. data/lib/less/js/test/browser/less/global-vars/simple.less +3 -0
  102. data/lib/less/js/test/browser/less/modify-vars/imports/simple2.less +4 -0
  103. data/lib/less/js/test/browser/less/modify-vars/simple.less +8 -0
  104. data/lib/less/js/test/browser/less/relative-urls/urls.less +1 -1
  105. data/lib/less/js/test/browser/less/rootpath-relative/urls.less +1 -1
  106. data/lib/less/js/test/browser/less/rootpath/urls.less +1 -1
  107. data/lib/less/js/test/browser/less/urls.less +9 -1
  108. data/lib/less/js/test/browser/phantom-runner.js +112 -103
  109. data/lib/less/js/test/browser/runner-browser-options.js +42 -0
  110. data/lib/less/js/test/browser/{runner-browser.js → runner-browser-spec.js} +7 -2
  111. data/lib/less/js/test/browser/runner-console-errors.js +5 -0
  112. data/lib/less/js/test/browser/runner-errors-options.js +5 -0
  113. data/lib/less/js/test/browser/runner-errors-spec.js +4 -0
  114. data/lib/less/js/test/browser/runner-global-vars-options.js +4 -0
  115. data/lib/less/js/test/browser/runner-global-vars-spec.js +3 -0
  116. data/lib/less/js/test/browser/runner-legacy-options.js +4 -0
  117. data/lib/less/js/test/browser/{runner-legacy.js → runner-legacy-spec.js} +1 -4
  118. data/lib/less/js/test/browser/runner-main-options.js +15 -0
  119. data/lib/less/js/test/browser/runner-main-spec.js +3 -0
  120. data/lib/less/js/test/browser/runner-modify-vars-options.js +2 -0
  121. data/lib/less/js/test/browser/runner-modify-vars-spec.js +43 -0
  122. data/lib/less/js/test/browser/runner-no-js-errors-options.js +4 -0
  123. data/lib/less/js/test/browser/runner-no-js-errors-spec.js +4 -0
  124. data/lib/less/js/test/browser/runner-production-options.js +3 -0
  125. data/lib/less/js/test/browser/{runner-production.js → runner-production-spec.js} +1 -3
  126. data/lib/less/js/test/browser/runner-relative-urls-options.js +3 -0
  127. data/lib/less/js/test/browser/{runner-relative-urls.js → runner-relative-urls-spec.js} +1 -2
  128. data/lib/less/js/test/browser/runner-rootpath-options.js +3 -0
  129. data/lib/less/js/test/browser/runner-rootpath-relative-options.js +4 -0
  130. data/lib/less/js/test/browser/{runner-rootpath-relative.js → runner-rootpath-relative-spec.js} +1 -3
  131. data/lib/less/js/test/browser/{runner-rootpath.js → runner-rootpath-spec.js} +1 -2
  132. data/lib/less/js/test/browser/test-runner-template.tmpl +47 -0
  133. data/lib/less/js/test/css/colors.css +7 -0
  134. data/lib/less/js/test/css/comments.css +9 -4
  135. data/lib/less/js/test/css/compression/compression.css +3 -2
  136. data/lib/less/js/test/css/css-3.css +17 -5
  137. data/lib/less/js/test/css/css-guards.css +37 -0
  138. data/lib/less/js/test/css/debug/linenumbers-all.css +6 -0
  139. data/lib/less/js/test/css/debug/linenumbers-comments.css +5 -0
  140. data/lib/less/js/test/css/debug/linenumbers-mediaquery.css +5 -0
  141. data/lib/less/js/test/css/empty.css +0 -0
  142. data/lib/less/js/test/css/extend-chaining.css +9 -0
  143. data/lib/less/js/test/css/extend-selector.css +10 -2
  144. data/lib/less/js/test/css/extract-and-length.css +133 -0
  145. data/lib/less/js/test/css/functions.css +23 -10
  146. data/lib/less/js/test/css/globalVars/extended.css +12 -0
  147. data/lib/less/js/test/css/globalVars/simple.css +6 -0
  148. data/lib/less/js/test/css/import-inline.css +5 -0
  149. data/lib/less/js/test/css/import-once.css +12 -0
  150. data/lib/less/js/test/css/import-reference.css +49 -0
  151. data/lib/less/js/test/css/import.css +0 -2
  152. data/lib/less/js/test/css/media.css +21 -5
  153. data/lib/less/js/test/css/merge.css +26 -0
  154. data/lib/less/js/test/css/mixins-guards-default-func.css +129 -0
  155. data/lib/less/js/test/css/mixins-guards.css +6 -0
  156. data/lib/less/js/test/css/mixins-important.css +7 -0
  157. data/lib/less/js/test/css/mixins-interpolated.css +39 -0
  158. data/lib/less/js/test/css/mixins.css +20 -0
  159. data/lib/less/js/test/css/modifyVars/extended.css +9 -0
  160. data/lib/less/js/test/css/no-output.css +0 -0
  161. data/lib/less/js/test/css/parens.css +3 -0
  162. data/lib/less/js/test/css/property-name-interp.css +20 -0
  163. data/lib/less/js/test/css/selectors.css +12 -0
  164. data/lib/less/js/test/css/static-urls/urls.css +7 -4
  165. data/lib/less/js/test/css/strings.css +3 -0
  166. data/lib/less/js/test/css/url-args/urls.css +56 -0
  167. data/lib/less/js/test/css/urls.css +21 -9
  168. data/lib/less/js/test/index.js +45 -0
  169. data/lib/less/js/test/less-test.js +234 -191
  170. data/lib/less/js/test/less/colors.less +6 -0
  171. data/lib/less/js/test/less/comments.less +7 -1
  172. data/lib/less/js/test/less/compression/compression.less +21 -1
  173. data/lib/less/js/test/less/css-3.less +12 -0
  174. data/lib/less/js/test/less/css-guards.less +99 -0
  175. data/lib/less/js/test/less/debug/linenumbers.less +11 -1
  176. data/lib/less/js/test/less/empty.less +0 -0
  177. data/lib/less/js/test/less/errors/add-mixed-units.txt +4 -2
  178. data/lib/less/js/test/less/errors/add-mixed-units2.txt +4 -2
  179. data/lib/less/js/test/less/errors/color-func-invalid-color.less +3 -0
  180. data/lib/less/js/test/less/errors/color-func-invalid-color.txt +4 -0
  181. data/lib/less/js/test/less/errors/css-guard-default-func.less +4 -0
  182. data/lib/less/js/test/less/errors/css-guard-default-func.txt +4 -0
  183. data/lib/less/js/test/less/errors/import-subfolder2.txt +4 -2
  184. data/lib/less/js/test/less/errors/javascript-undefined-var.less +3 -0
  185. data/lib/less/js/test/less/errors/javascript-undefined-var.txt +4 -0
  186. data/lib/less/js/test/less/errors/mixins-guards-default-func-1.less +9 -0
  187. data/lib/less/js/test/less/errors/mixins-guards-default-func-1.txt +4 -0
  188. data/lib/less/js/test/less/errors/mixins-guards-default-func-2.less +9 -0
  189. data/lib/less/js/test/less/errors/mixins-guards-default-func-2.txt +4 -0
  190. data/lib/less/js/test/less/errors/mixins-guards-default-func-3.less +9 -0
  191. data/lib/less/js/test/less/errors/mixins-guards-default-func-3.txt +4 -0
  192. data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors.less +4 -0
  193. data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors.txt +4 -0
  194. data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors2.less +4 -0
  195. data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors2.txt +4 -0
  196. data/lib/less/js/test/less/errors/parse-error-curly-bracket.less +4 -1
  197. data/lib/less/js/test/less/errors/parse-error-curly-bracket.txt +4 -2
  198. data/lib/less/js/test/less/errors/parse-error-extra-parens.less +5 -0
  199. data/lib/less/js/test/less/errors/parse-error-extra-parens.txt +3 -0
  200. data/lib/less/js/test/less/errors/parse-error-missing-bracket.txt +2 -2
  201. data/lib/less/js/test/less/errors/parse-error-missing-parens.less +5 -0
  202. data/lib/less/js/test/less/errors/parse-error-missing-parens.txt +3 -0
  203. data/lib/less/js/test/less/errors/property-asterisk-only-name.less +3 -0
  204. data/lib/less/js/test/less/errors/property-asterisk-only-name.txt +4 -0
  205. data/lib/less/js/test/less/errors/property-interp-not-defined.less +1 -0
  206. data/lib/less/js/test/less/errors/property-interp-not-defined.txt +2 -0
  207. data/lib/less/js/test/less/errors/svg-gradient1.less +3 -0
  208. data/lib/less/js/test/less/errors/svg-gradient1.txt +4 -0
  209. data/lib/less/js/test/less/errors/svg-gradient2.less +3 -0
  210. data/lib/less/js/test/less/errors/svg-gradient2.txt +4 -0
  211. data/lib/less/js/test/less/errors/svg-gradient3.less +3 -0
  212. data/lib/less/js/test/less/errors/svg-gradient3.txt +4 -0
  213. data/lib/less/js/test/less/errors/unit-function.less +3 -0
  214. data/lib/less/js/test/less/errors/unit-function.txt +4 -0
  215. data/lib/less/js/test/less/extend-chaining.less +12 -0
  216. data/lib/less/js/test/less/extend-selector.less +15 -0
  217. data/lib/less/js/test/less/extract-and-length.less +133 -0
  218. data/lib/less/js/test/less/functions.less +15 -2
  219. data/lib/less/js/test/less/globalVars/extended.json +5 -0
  220. data/lib/less/js/test/less/globalVars/extended.less +10 -0
  221. data/lib/less/js/test/less/globalVars/simple.json +3 -0
  222. data/lib/less/js/test/less/globalVars/simple.less +3 -0
  223. data/lib/less/js/test/less/import-inline.less +2 -0
  224. data/lib/less/js/test/less/import-once.less +2 -0
  225. data/lib/less/js/test/less/import-reference.less +18 -0
  226. data/lib/less/js/test/less/import/import-and-relative-paths-test.less +11 -0
  227. data/lib/less/js/test/less/import/import-reference.less +43 -0
  228. data/lib/less/js/test/less/import/import-test-f.less +5 -0
  229. data/lib/less/js/test/less/import/invalid-css.less +1 -0
  230. data/lib/less/js/test/less/media.less +25 -1
  231. data/lib/less/js/test/less/merge.less +59 -0
  232. data/lib/less/js/test/less/mixins-args.less +10 -0
  233. data/lib/less/js/test/less/mixins-guards-default-func.less +195 -0
  234. data/lib/less/js/test/less/mixins-guards.less +16 -0
  235. data/lib/less/js/test/less/mixins-important.less +4 -1
  236. data/lib/less/js/test/less/mixins-interpolated.less +69 -0
  237. data/lib/less/js/test/less/mixins.less +27 -0
  238. data/lib/less/js/test/less/modifyVars/extended.json +5 -0
  239. data/lib/less/js/test/less/modifyVars/extended.less +11 -0
  240. data/lib/less/js/test/less/no-js-errors/no-js-errors.less +3 -0
  241. data/lib/less/js/test/less/no-js-errors/no-js-errors.txt +4 -0
  242. data/lib/less/js/test/less/no-output.less +2 -0
  243. data/lib/less/js/test/less/parens.less +4 -0
  244. data/lib/less/js/test/less/property-name-interp.less +53 -0
  245. data/lib/less/js/test/less/selectors.less +13 -0
  246. data/lib/less/js/test/less/sourcemaps/basic.json +3 -0
  247. data/lib/less/js/test/less/sourcemaps/basic.less +27 -0
  248. data/lib/less/js/test/less/sourcemaps/imported.css +7 -0
  249. data/lib/less/js/test/less/strings.less +6 -0
  250. data/lib/less/js/test/less/url-args/urls.less +63 -0
  251. data/lib/less/js/test/less/urls.less +15 -0
  252. data/lib/less/js/test/rhino/test-header.js +15 -0
  253. data/lib/less/js/test/sourcemaps/basic.json +1 -0
  254. data/lib/less/js/test/sourcemaps/index.html +17 -0
  255. data/lib/less/loader.rb +48 -40
  256. data/lib/less/version.rb +1 -1
  257. data/spec/less/parser_spec.rb +15 -15
  258. metadata +146 -40
  259. data/lib/less/js/Makefile +0 -102
  260. data/lib/less/js/build/header.js +0 -9
  261. data/lib/less/js/test/browser-test-prepare.js +0 -46
  262. data/lib/less/js/test/browser/runner-errors.js +0 -5
  263. data/lib/less/js/test/browser/runner-main.js +0 -15
  264. data/lib/less/js/test/browser/template.htm +0 -10
  265. data/lib/less/js/test/less/errors/color-operation-error.txt +0 -2
@@ -0,0 +1,27 @@
1
+ /*
2
+ PhantomJS does not implement bind. this is from
3
+ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
4
+ */
5
+ if (!Function.prototype.bind) {
6
+ Function.prototype.bind = function (oThis) {
7
+ if (typeof this !== "function") {
8
+ // closest thing possible to the ECMAScript 5 internal IsCallable function
9
+ throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
10
+ }
11
+
12
+ var aArgs = Array.prototype.slice.call(arguments, 1),
13
+ fToBind = this,
14
+ fNOP = function () {},
15
+ fBound = function () {
16
+ return fToBind.apply(this instanceof fNOP && oThis
17
+ ? this
18
+ : oThis,
19
+ aArgs.concat(Array.prototype.slice.call(arguments)));
20
+ };
21
+
22
+ fNOP.prototype = this.prototype;
23
+ fBound.prototype = new fNOP();
24
+
25
+ return fBound;
26
+ };
27
+ }
@@ -0,0 +1,2 @@
1
+ less: OperationError: Can't substract or divide a color from a number in {pathhref}console-errors/test-error.less on line null, column 0:
2
+ 1 prop: (3 / #fff);
@@ -0,0 +1,3 @@
1
+ .test {
2
+ color: @global-var;
3
+ }
@@ -0,0 +1,4 @@
1
+ @var2: blue;
2
+ .testisimported {
3
+ color: gainsboro;
4
+ }
@@ -0,0 +1,8 @@
1
+ @import "imports/simple2";
2
+ @var1: red;
3
+ @scale: 10;
4
+ .test {
5
+ color1: @var1;
6
+ color2: @var2;
7
+ scalar: @scale
8
+ }
@@ -1,5 +1,5 @@
1
1
  @import ".././imports/urls.less";
2
- @import "http://localhost:8081/browser/less/imports/urls2.less";
2
+ @import "http://localhost:8081/test/browser/less/imports/urls2.less";
3
3
  @font-face {
4
4
  src: url("/fonts/garamond-pro.ttf");
5
5
  src: local(Futura-Medium),
@@ -1,5 +1,5 @@
1
1
  @import "../imports/urls.less";
2
- @import "http://localhost:8081/browser/less/imports/urls2.less";
2
+ @import "http://localhost:8081/test/browser/less/imports/urls2.less";
3
3
  @font-face {
4
4
  src: url("/fonts/garamond-pro.ttf");
5
5
  src: local(Futura-Medium),
@@ -1,5 +1,5 @@
1
1
  @import "../imports/urls.less";
2
- @import "http://localhost:8081/browser/less/imports/urls2.less";
2
+ @import "http://localhost:8081/test/browser/less/imports/urls2.less";
3
3
  @font-face {
4
4
  src: url("/fonts/garamond-pro.ttf");
5
5
  src: local(Futura-Medium),
@@ -1,5 +1,5 @@
1
1
  @import "imports/urls.less";
2
- @import "http://localhost:8081/browser/less/imports/urls2.less";
2
+ @import "http://localhost:8081/test/browser/less/imports/urls2.less";
3
3
  @font-face {
4
4
  src: url("/fonts/garamond-pro.ttf");
5
5
  src: local(Futura-Medium),
@@ -47,3 +47,11 @@
47
47
  #data-uri-toobig {
48
48
  uri: data-uri('../../data/data-uri-fail.png');
49
49
  }
50
+ #svg-functions {
51
+ background-image: svg-gradient(to bottom, black, white);
52
+ background-image: svg-gradient(to bottom, black, orange 3%, white);
53
+ @green_5: green 5%;
54
+ @orange_percentage: 3%;
55
+ @orange_color: orange;
56
+ background-image: svg-gradient(to bottom, (mix(black, white) + #444) 1%, @orange_color @orange_percentage, ((@green_5)), white 95%);
57
+ }
@@ -2,31 +2,35 @@ var webpage = require('webpage');
2
2
  var server = require('webserver').create();
3
3
  var system = require('system');
4
4
  var fs = require('fs');
5
- var host, port = 8081;
5
+ var host;
6
+ var port = 8081;
6
7
 
7
- var listening = server.listen(port, function (request, response) {
8
- //console.log("Requested "+request.url);
9
-
10
- var filename = ("test/" + request.url.slice(1)).replace(/[\\\/]/g, fs.separator);
11
-
12
- if (!fs.exists(filename) || !fs.isFile(filename)) {
13
- response.statusCode = 404;
14
- response.write("<html><head></head><body><h1>File Not Found</h1><h2>File:"+filename+"</h2></body></html>");
15
- response.close();
16
- return;
17
- }
8
+ var listening = server.listen(port, function(request, response) {
9
+ //console.log("Requested " + request.url);
10
+
11
+ var filename = ("test/" + request.url.slice(1)).replace(/[\\\/]/g, fs.separator);
18
12
 
19
- // we set the headers here
20
- response.statusCode = 200;
21
- response.headers = {"Cache": "no-cache", "Content-Type": "text/html"};
22
-
23
- response.write(fs.read(filename));
24
-
13
+ if (!fs.exists(filename) || !fs.isFile(filename)) {
14
+ response.statusCode = 404;
15
+ response.write("<html><head></head><body><h1>File Not Found</h1><h2>File:" + filename + "</h2></body></html>");
25
16
  response.close();
17
+ return;
18
+ }
19
+
20
+ // we set the headers here
21
+ response.statusCode = 200;
22
+ response.headers = {
23
+ "Cache": "no-cache",
24
+ "Content-Type": "text/html"
25
+ };
26
+
27
+ response.write(fs.read(filename));
28
+
29
+ response.close();
26
30
  });
27
31
  if (!listening) {
28
- console.log("could not create web server listening on port " + port);
29
- phantom.exit();
32
+ console.log("could not create web server listening on port " + port);
33
+ phantom.exit();
30
34
  }
31
35
 
32
36
  /**
@@ -42,100 +46,105 @@ if (!listening) {
42
46
  * @param timeOutMillis the max amount of time to wait. If not specified, 3 sec is used.
43
47
  * @param timeOutErrorMessage the error message if time out occurs
44
48
  */
45
- function waitFor(testFx, onReady, timeOutMillis, timeOutErrorMessage) {
46
- var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 10001, //< Default Max Timeout is 10s
47
- start = new Date().getTime(),
48
- condition = false,
49
- interval = setInterval(function() {
50
- if ( (new Date().getTime() - start < maxtimeOutMillis) && !condition ) {
51
- // If not time-out yet and condition not yet fulfilled
52
- condition = (typeof(testFx) === "string" ? eval(testFx) : testFx()); //< defensive code
53
- } else {
54
- if(!condition) {
55
- // If condition still not fulfilled (timeout but condition is 'false')
56
- console.log(timeOutErrorMessage || "'waitFor()' timeout");
57
- phantom.exit(1);
58
- } else {
59
- // Condition fulfilled (timeout and/or condition is 'true')
60
- typeof(onReady) === "string" ? eval(onReady) : onReady(); //< Do what it's supposed to do once the condition is fulfilled
61
- clearInterval(interval); //< Stop this interval
62
- }
63
- }
64
- }, 100); //< repeat check every 100ms
65
- };
66
49
 
67
- function testPage(url) {
68
- var page = webpage.create();
69
- page.open(url, function (status) {
70
- if (status !== "success") {
71
- console.log("Unable to access network - " + status);
72
- phantom.exit();
50
+ function waitFor(testFx, onReady, timeOutMillis, timeOutErrorMessage) {
51
+ var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 10001, //< Default Max Timeout is 10s
52
+ start = new Date().getTime(),
53
+ condition = false,
54
+ interval = setInterval(function() {
55
+ if ((new Date().getTime() - start < maxtimeOutMillis) && !condition) {
56
+ // If not time-out yet and condition not yet fulfilled
57
+ condition = (typeof(testFx) === "string" ? eval(testFx) : testFx()); //< defensive code
58
+ } else {
59
+ if (!condition) {
60
+ // If condition still not fulfilled (timeout but condition is 'false')
61
+ console.log(timeOutErrorMessage || "'waitFor()' timeout");
62
+ phantom.exit(1);
73
63
  } else {
74
- waitFor(function(){
75
- return page.evaluate(function(){
76
- return document.body && document.body.querySelector &&
77
- document.body.querySelector('.symbolSummary .pending') === null &&
78
- document.body.querySelector('.results') !== null;
79
- });
80
- }, function(){
81
- page.onConsoleMessage = function (msg) {
82
- console.log(msg);
83
- };
84
- var exitCode = page.evaluate(function(){
85
- console.log('');
86
- console.log(document.body.querySelector('.description').innerText);
87
- var list = document.body.querySelectorAll('.results > #details > .specDetail.failed');
88
- if (list && list.length > 0) {
89
- console.log('');
90
- console.log(list.length + ' test(s) FAILED:');
91
- for (var i = 0; i < list.length; ++i) {
92
- var el = list[i],
93
- desc = el.querySelector('.description'),
94
- msg = el.querySelector('.resultMessage.fail');
95
- console.log('');
96
- console.log(desc.innerText);
97
- console.log(msg.innerText);
98
- console.log('');
99
- }
100
- return 1;
101
- } else {
102
- console.log(document.body.querySelector('.alert > .passingAlert.bar').innerText);
103
- return 0;
104
- }
105
- });
106
- testFinished(exitCode);
107
- },
108
- 10000, // 10 second timeout
109
- "Test failed waiting for jasmine results on page: " + url);
64
+ // Condition fulfilled (timeout and/or condition is 'true')
65
+ typeof(onReady) === "string" ? eval(onReady) : onReady(); //< Do what it's supposed to do once the condition is fulfilled
66
+ clearInterval(interval); //< Stop this interval
110
67
  }
111
- });
68
+ }
69
+ }, 100); //< repeat check every 100ms
70
+ }
71
+
72
+ function testPage(url) {
73
+ var page = webpage.create();
74
+ page.open(url, function(status) {
75
+ if (status !== "success") {
76
+ console.log("Unable to access network - " + status);
77
+ phantom.exit();
78
+ } else {
79
+ waitFor(function() {
80
+ return page.evaluate(function() {
81
+ return document.body && document.body.querySelector &&
82
+ document.body.querySelector('.symbolSummary .pending') === null &&
83
+ document.body.querySelector('.results') !== null;
84
+ });
85
+ }, function() {
86
+ page.onConsoleMessage = function(msg) {
87
+ console.log(msg);
88
+ };
89
+ var exitCode = page.evaluate(function() {
90
+ console.log('');
91
+ console.log(document.body.querySelector('.description').innerText);
92
+ var list = document.body.querySelectorAll('.results > #details > .specDetail.failed');
93
+ if (list && list.length > 0) {
94
+ console.log('');
95
+ console.log(list.length + ' test(s) FAILED:');
96
+ for (var i = 0; i < list.length; ++i) {
97
+ var el = list[i],
98
+ desc = el.querySelector('.description'),
99
+ msg = el.querySelector('.resultMessage.fail');
100
+ console.log('');
101
+ console.log(desc.innerText);
102
+ console.log(msg.innerText);
103
+ console.log('');
104
+ }
105
+ return 1;
106
+ } else {
107
+ console.log(document.body.querySelector('.alert > .passingAlert.bar').innerText);
108
+ return 0;
109
+ }
110
+ });
111
+ testFinished(exitCode);
112
+ },
113
+ 10000, // 10 second timeout
114
+ "Test failed waiting for jasmine results on page: " + url);
115
+ }
116
+ });
112
117
  }
113
118
 
114
119
  function scanDirectory(path, regex) {
115
- var files = [];
116
- fs.list(path).forEach(function (file) {
117
- if (file.match(regex)) {
118
- files.push(file);
119
- }
120
- });
121
- return files;
122
- };
120
+ var files = [];
121
+ fs.list(path).forEach(function(file) {
122
+ if (file.match(regex)) {
123
+ files.push(file);
124
+ }
125
+ });
126
+ return files;
127
+ }
123
128
 
124
129
  var totalTests = 0,
125
- totalFailed = 0,
126
- totalDone = 0;
130
+ totalFailed = 0,
131
+ totalDone = 0;
127
132
 
128
133
  function testFinished(failed) {
129
- if (failed) { totalFailed++; }
130
- totalDone++;
131
- if (totalDone === totalTests) { phantom.exit(totalFailed > 0 ? 1 : 0); }
134
+ if (failed) {
135
+ totalFailed++;
136
+ }
137
+ totalDone++;
138
+ if (totalDone === totalTests) {
139
+ phantom.exit(totalFailed > 0 ? 1 : 0);
140
+ }
132
141
  }
133
142
 
134
143
  if (system.args.length != 2 && system.args[1] != "--no-tests") {
135
- var files = scanDirectory("test/browser/", /^test-runner-.+\.htm$/);
136
- totalTests = files.length;
137
- console.log("found " + files.length + " tests");
138
- files.forEach(function(file) {
139
- testPage("http://localhost:8081/browser/" + file);
140
- });
144
+ var files = scanDirectory("test/browser/", /^test-runner-.+\.htm$/);
145
+ totalTests = files.length;
146
+ console.log("found " + files.length + " tests");
147
+ files.forEach(function(file) {
148
+ testPage("http://localhost:8081/browser/" + file);
149
+ });
141
150
  }
@@ -0,0 +1,42 @@
1
+ var less = {};
2
+
3
+ // There originally run inside describe method. However, since they have not
4
+ // been inside it, they run at jasmine compile time (not runtime). It all
5
+ // worked cause less.js was in async mode and custom phantom runner had
6
+ // different setup then grunt-contrib-jasmine. They have been created before
7
+ // less.js run, even as they have been defined in spec.
8
+
9
+ // test inline less in style tags by grabbing an assortment of less files and doing `@import`s
10
+ var testFiles = ['charsets', 'colors', 'comments', 'css-3', 'strings', 'media', 'mixins'],
11
+ testSheets = [];
12
+
13
+ // setup style tags with less and link tags pointing to expected css output
14
+ for (var i = 0; i < testFiles.length; i++) {
15
+ var file = testFiles[i],
16
+ lessPath = '/test/less/' + file + '.less',
17
+ cssPath = '/test/css/' + file + '.css',
18
+ lessStyle = document.createElement('style'),
19
+ cssLink = document.createElement('link'),
20
+ lessText = '@import "' + lessPath + '";';
21
+
22
+ lessStyle.type = 'text/less';
23
+ lessStyle.id = file;
24
+ lessStyle.href = file;
25
+
26
+ if (lessStyle.styleSheet) {
27
+ lessStyle.styleSheet.cssText = lessText;
28
+ } else {
29
+ lessStyle.innerHTML = lessText;
30
+ }
31
+
32
+ cssLink.rel = 'stylesheet';
33
+ cssLink.type = 'text/css';
34
+ cssLink.href = cssPath;
35
+ cssLink.id = 'expected-' + file;
36
+
37
+ var head = document.getElementsByTagName('head')[0];
38
+
39
+ head.appendChild(lessStyle);
40
+ head.appendChild(cssLink);
41
+ testSheets[i] = lessStyle;
42
+ }
@@ -1,7 +1,12 @@
1
1
  describe("less.js browser behaviour", function() {
2
2
  testLessEqualsInDocument();
3
-
3
+
4
4
  it("has some log messages", function() {
5
5
  expect(logMessages.length).toBeGreaterThan(0);
6
6
  });
7
- });
7
+
8
+ for (var i = 0; i < testFiles.length; i++) {
9
+ var sheet = testSheets[i];
10
+ testSheet(sheet);
11
+ }
12
+ });
@@ -0,0 +1,5 @@
1
+ less.errorReporting = 'console';
2
+
3
+ describe("less.js error reporting console test", function() {
4
+ testLessErrorsInDocument(true);
5
+ });
@@ -0,0 +1,5 @@
1
+ var less = {
2
+ strictUnits: true,
3
+ strictMath: true
4
+ };
5
+
@@ -0,0 +1,4 @@
1
+ describe("less.js error tests", function() {
2
+ testLessErrorsInDocument();
3
+ });
4
+
@@ -0,0 +1,4 @@
1
+ var less = {};
2
+ less.globalVars = {
3
+ "@global-var": "red"
4
+ };
@@ -0,0 +1,3 @@
1
+ describe("less.js global vars", function() {
2
+ testLessEqualsInDocument();
3
+ });
@@ -0,0 +1,4 @@
1
+ var less = {};
2
+ less.strictMath = false;
3
+ less.strictUnits = false;
4
+
@@ -1,6 +1,3 @@
1
- less.strictMath = false;
2
- less.strictUnits = false;
3
-
4
1
  describe("less.js legacy tests", function() {
5
2
  testLessEqualsInDocument();
6
- });
3
+ });
@@ -0,0 +1,15 @@
1
+ var less = {};
2
+ less.strictMath = true;
3
+ less.functions = {
4
+ add: function(a, b) {
5
+ return new(less.tree.Dimension)(a.value + b.value);
6
+ },
7
+ increment: function(a) {
8
+ return new(less.tree.Dimension)(a.value + 1);
9
+ },
10
+ _color: function(str) {
11
+ if (str.value === "evil red") {
12
+ return new(less.tree.Color)("600");
13
+ }
14
+ }
15
+ };