guard-mthaml 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (341) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +34 -0
  3. data/lib/guard/mthaml.rb +140 -0
  4. data/lib/guard/mthaml/compiler/MtHaml.php +255 -0
  5. data/lib/guard/mthaml/templates/Guardfile +12 -0
  6. data/lib/guard/mthaml/version.rb +5 -0
  7. data/vendor/autoload.php +7 -0
  8. data/vendor/coffeescript/coffeescript/LICENSE +22 -0
  9. data/vendor/coffeescript/coffeescript/README.md +96 -0
  10. data/vendor/coffeescript/coffeescript/composer.json +23 -0
  11. data/vendor/coffeescript/coffeescript/grammar.y +309 -0
  12. data/vendor/coffeescript/coffeescript/make.php +115 -0
  13. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Compiler.php +76 -0
  14. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Error.php +15 -0
  15. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Helpers.php +116 -0
  16. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Init.php +96 -0
  17. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Lexer.php +1356 -0
  18. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Nodes.php +105 -0
  19. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Parser.php +3326 -0
  20. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Rewriter.php +552 -0
  21. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Scope.php +196 -0
  22. data/vendor/coffeescript/coffeescript/src/CoffeeScript/SyntaxError.php +9 -0
  23. data/vendor/coffeescript/coffeescript/src/CoffeeScript/Value.php +20 -0
  24. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Access.php +31 -0
  25. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Arr.php +69 -0
  26. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Assign.php +353 -0
  27. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Base.php +288 -0
  28. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Block.php +294 -0
  29. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Call.php +283 -0
  30. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Class.php +282 -0
  31. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Closure.php +49 -0
  32. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Code.php +203 -0
  33. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Comment.php +39 -0
  34. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Existence.php +42 -0
  35. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Extends.php +26 -0
  36. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/For.php +250 -0
  37. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/If.php +161 -0
  38. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/In.php +99 -0
  39. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Index.php +27 -0
  40. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Literal.php +96 -0
  41. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Obj.php +126 -0
  42. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Op.php +292 -0
  43. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Param.php +119 -0
  44. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Parens.php +45 -0
  45. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Range.php +225 -0
  46. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Return.php +56 -0
  47. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Slice.php +47 -0
  48. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Splat.php +100 -0
  49. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Switch.php +121 -0
  50. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Throw.php +37 -0
  51. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Try.php +79 -0
  52. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Value.php +210 -0
  53. data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/While.php +112 -0
  54. data/vendor/coffeescript/coffeescript/tests/cases/arrays.coffee +77 -0
  55. data/vendor/coffeescript/coffeescript/tests/cases/assignment.coffee +352 -0
  56. data/vendor/coffeescript/coffeescript/tests/cases/booleans.coffee +21 -0
  57. data/vendor/coffeescript/coffeescript/tests/cases/classes.coffee +681 -0
  58. data/vendor/coffeescript/coffeescript/tests/cases/comments.coffee +207 -0
  59. data/vendor/coffeescript/coffeescript/tests/cases/compilation.coffee +72 -0
  60. data/vendor/coffeescript/coffeescript/tests/cases/comprehensions.coffee +501 -0
  61. data/vendor/coffeescript/coffeescript/tests/cases/control_flow.coffee +430 -0
  62. data/vendor/coffeescript/coffeescript/tests/cases/eval.coffee +29 -0
  63. data/vendor/coffeescript/coffeescript/tests/cases/exception_handling.coffee +102 -0
  64. data/vendor/coffeescript/coffeescript/tests/cases/formatting.coffee +146 -0
  65. data/vendor/coffeescript/coffeescript/tests/cases/function_invocation.coffee +552 -0
  66. data/vendor/coffeescript/coffeescript/tests/cases/functions.coffee +188 -0
  67. data/vendor/coffeescript/coffeescript/tests/cases/helpers.coffee +96 -0
  68. data/vendor/coffeescript/coffeescript/tests/cases/importing.coffee +18 -0
  69. data/vendor/coffeescript/coffeescript/tests/cases/interpolation.coffee +138 -0
  70. data/vendor/coffeescript/coffeescript/tests/cases/javascript_literals.coffee +10 -0
  71. data/vendor/coffeescript/coffeescript/tests/cases/numbers.coffee +76 -0
  72. data/vendor/coffeescript/coffeescript/tests/cases/objects.coffee +271 -0
  73. data/vendor/coffeescript/coffeescript/tests/cases/operators.coffee +277 -0
  74. data/vendor/coffeescript/coffeescript/tests/cases/option_parser.coffee +43 -0
  75. data/vendor/coffeescript/coffeescript/tests/cases/ranges.coffee +88 -0
  76. data/vendor/coffeescript/coffeescript/tests/cases/regexps.coffee +63 -0
  77. data/vendor/coffeescript/coffeescript/tests/cases/scope.coffee +43 -0
  78. data/vendor/coffeescript/coffeescript/tests/cases/slicing_and_splicing.coffee +143 -0
  79. data/vendor/coffeescript/coffeescript/tests/cases/soaks.coffee +134 -0
  80. data/vendor/coffeescript/coffeescript/tests/cases/strict.coffee +155 -0
  81. data/vendor/coffeescript/coffeescript/tests/cases/strings.coffee +107 -0
  82. data/vendor/coffeescript/coffeescript/tests/css/style.css +43 -0
  83. data/vendor/coffeescript/coffeescript/tests/index.php +119 -0
  84. data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.1.1.js +8 -0
  85. data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.2.0.js +8 -0
  86. data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.3.0.js +8 -0
  87. data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.3.1.js +8 -0
  88. data/vendor/coffeescript/coffeescript/tests/js/lib/diff.js +276 -0
  89. data/vendor/coffeescript/coffeescript/tests/js/main.js +123 -0
  90. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/LICENSE.txt +10 -0
  91. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/Lempar.php +948 -0
  92. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Action.php +257 -0
  93. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/ActionTable.php +299 -0
  94. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Config.php +574 -0
  95. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Data.php +1857 -0
  96. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Parser.php +851 -0
  97. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/PropagationLink.php +126 -0
  98. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Rule.php +144 -0
  99. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/State.php +283 -0
  100. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Symbol.php +288 -0
  101. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/cli.php +5 -0
  102. data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/ParserGenerator.php +811 -0
  103. data/vendor/composer/ClassLoader.php +383 -0
  104. data/vendor/composer/autoload_classmap.php +9 -0
  105. data/vendor/composer/autoload_namespaces.php +12 -0
  106. data/vendor/composer/autoload_psr4.php +10 -0
  107. data/vendor/composer/autoload_real.php +50 -0
  108. data/vendor/composer/installed.json +166 -0
  109. data/vendor/michelf/php-markdown/License.md +36 -0
  110. data/vendor/michelf/php-markdown/Michelf/Markdown.inc.php +10 -0
  111. data/vendor/michelf/php-markdown/Michelf/Markdown.php +3117 -0
  112. data/vendor/michelf/php-markdown/Michelf/MarkdownExtra.inc.php +11 -0
  113. data/vendor/michelf/php-markdown/Michelf/MarkdownExtra.php +38 -0
  114. data/vendor/michelf/php-markdown/Michelf/MarkdownInterface.inc.php +9 -0
  115. data/vendor/michelf/php-markdown/Michelf/MarkdownInterface.php +37 -0
  116. data/vendor/michelf/php-markdown/Readme.md +305 -0
  117. data/vendor/michelf/php-markdown/Readme.php +31 -0
  118. data/vendor/michelf/php-markdown/composer.json +31 -0
  119. data/vendor/mthaml/mthaml/CHANGELOG +48 -0
  120. data/vendor/mthaml/mthaml/LICENSE +44 -0
  121. data/vendor/mthaml/mthaml/README.markdown +262 -0
  122. data/vendor/mthaml/mthaml/composer.json +45 -0
  123. data/vendor/mthaml/mthaml/docs/Makefile +153 -0
  124. data/vendor/mthaml/mthaml/docs/_static/mthaml.css +30 -0
  125. data/vendor/mthaml/mthaml/docs/_theme/mthaml/theme.conf +4 -0
  126. data/vendor/mthaml/mthaml/docs/conf.py +242 -0
  127. data/vendor/mthaml/mthaml/docs/index.rst +18 -0
  128. data/vendor/mthaml/mthaml/docs/twig-syntax.rst +274 -0
  129. data/vendor/mthaml/mthaml/examples/README.md +5 -0
  130. data/vendor/mthaml/mthaml/examples/autoload.php +8 -0
  131. data/vendor/mthaml/mthaml/examples/example-php.haml +5 -0
  132. data/vendor/mthaml/mthaml/examples/example-php.php +37 -0
  133. data/vendor/mthaml/mthaml/examples/example-twig-noext.twig +11 -0
  134. data/vendor/mthaml/mthaml/examples/example-twig.haml +9 -0
  135. data/vendor/mthaml/mthaml/examples/example-twig.php +60 -0
  136. data/vendor/mthaml/mthaml/examples/example.twig.haml +8 -0
  137. data/vendor/mthaml/mthaml/lib/MtHaml/Autoloader.php +22 -0
  138. data/vendor/mthaml/mthaml/lib/MtHaml/Environment.php +178 -0
  139. data/vendor/mthaml/mthaml/lib/MtHaml/Escaping.php +33 -0
  140. data/vendor/mthaml/mthaml/lib/MtHaml/Exception.php +9 -0
  141. data/vendor/mthaml/mthaml/lib/MtHaml/Exception/SyntaxErrorException.php +9 -0
  142. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/AbstractFilter.php +43 -0
  143. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Cdata.php +16 -0
  144. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/CoffeeScript.php +33 -0
  145. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Css.php +26 -0
  146. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Escaped.php +22 -0
  147. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/FilterInterface.php +15 -0
  148. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Javascript.php +26 -0
  149. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Less.php +27 -0
  150. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Less/LeafoLess.php +20 -0
  151. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Less/OyejorgeLess.php +23 -0
  152. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown.php +58 -0
  153. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/CebeMarkdown.php +22 -0
  154. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/Ciconia.php +21 -0
  155. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/MichelfMarkdown.php +21 -0
  156. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/Parsedown.php +21 -0
  157. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Php.php +37 -0
  158. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Plain.php +24 -0
  159. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Preserve.php +19 -0
  160. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Scss.php +37 -0
  161. data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Twig.php +47 -0
  162. data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/Indentation.php +96 -0
  163. data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/IndentationException.php +9 -0
  164. data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/IndentationInterface.php +50 -0
  165. data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/Undefined.php +41 -0
  166. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Comment.php +71 -0
  167. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Doctype.php +96 -0
  168. data/vendor/mthaml/mthaml/lib/MtHaml/Node/EscapableAbstract.php +19 -0
  169. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Filter.php +51 -0
  170. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Insert.php +42 -0
  171. data/vendor/mthaml/mthaml/lib/MtHaml/Node/InterpolatedString.php +73 -0
  172. data/vendor/mthaml/mthaml/lib/MtHaml/Node/NestAbstract.php +117 -0
  173. data/vendor/mthaml/mthaml/lib/MtHaml/Node/NestInterface.php +10 -0
  174. data/vendor/mthaml/mthaml/lib/MtHaml/Node/NodeAbstract.php +77 -0
  175. data/vendor/mthaml/mthaml/lib/MtHaml/Node/ObjectRefClass.php +42 -0
  176. data/vendor/mthaml/mthaml/lib/MtHaml/Node/ObjectRefId.php +42 -0
  177. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Root.php +35 -0
  178. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Run.php +71 -0
  179. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Statement.php +45 -0
  180. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Tag.php +90 -0
  181. data/vendor/mthaml/mthaml/lib/MtHaml/Node/TagAttribute.php +62 -0
  182. data/vendor/mthaml/mthaml/lib/MtHaml/Node/TagAttributeInterpolation.php +24 -0
  183. data/vendor/mthaml/mthaml/lib/MtHaml/Node/TagAttributeList.php +24 -0
  184. data/vendor/mthaml/mthaml/lib/MtHaml/Node/Text.php +37 -0
  185. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Autoclose.php +25 -0
  186. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Escaping.php +105 -0
  187. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/MergeAttrs.php +110 -0
  188. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Midblock.php +37 -0
  189. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/NodeVisitorAbstract.php +226 -0
  190. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/NodeVisitorInterface.php +97 -0
  191. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/PhpRenderer.php +288 -0
  192. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Printer.php +265 -0
  193. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/RendererAbstract.php +581 -0
  194. data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/TwigRenderer.php +252 -0
  195. data/vendor/mthaml/mthaml/lib/MtHaml/Parser.php +862 -0
  196. data/vendor/mthaml/mthaml/lib/MtHaml/Parser/Buffer.php +147 -0
  197. data/vendor/mthaml/mthaml/lib/MtHaml/Runtime.php +218 -0
  198. data/vendor/mthaml/mthaml/lib/MtHaml/Runtime/AttributeInterpolation.php +16 -0
  199. data/vendor/mthaml/mthaml/lib/MtHaml/Runtime/AttributeList.php +16 -0
  200. data/vendor/mthaml/mthaml/lib/MtHaml/Support/Php/Executor.php +157 -0
  201. data/vendor/mthaml/mthaml/lib/MtHaml/Support/Twig/Extension.php +47 -0
  202. data/vendor/mthaml/mthaml/lib/MtHaml/Support/Twig/Lexer.php +48 -0
  203. data/vendor/mthaml/mthaml/lib/MtHaml/Support/Twig/Loader.php +81 -0
  204. data/vendor/mthaml/mthaml/lib/MtHaml/Target/Php.php +23 -0
  205. data/vendor/mthaml/mthaml/lib/MtHaml/Target/TargetAbstract.php +87 -0
  206. data/vendor/mthaml/mthaml/lib/MtHaml/Target/TargetInterface.php +12 -0
  207. data/vendor/mthaml/mthaml/lib/MtHaml/Target/Twig.php +23 -0
  208. data/vendor/mthaml/mthaml/lib/MtHaml/TreeBuilder.php +100 -0
  209. data/vendor/mthaml/mthaml/lib/MtHaml/TreeBuilderException.php +9 -0
  210. data/vendor/mthaml/mthaml/phpunit.xml +25 -0
  211. data/vendor/mthaml/mthaml/test/MtHaml/Tests/EnvironmentTest.php +59 -0
  212. data/vendor/mthaml/mthaml/test/MtHaml/Tests/HamlSpecTest.php +83 -0
  213. data/vendor/mthaml/mthaml/test/MtHaml/Tests/IndentationTest.php +140 -0
  214. data/vendor/mthaml/mthaml/test/MtHaml/Tests/Node/DoctypeTest.php +51 -0
  215. data/vendor/mthaml/mthaml/test/MtHaml/Tests/Node/NodeTest.php +110 -0
  216. data/vendor/mthaml/mthaml/test/MtHaml/Tests/NodeVisitor/PhpRendererTest.php +113 -0
  217. data/vendor/mthaml/mthaml/test/MtHaml/Tests/NodeVisitor/TwigRendererTest.php +68 -0
  218. data/vendor/mthaml/mthaml/test/MtHaml/Tests/NodeVisitorsTest.php +44 -0
  219. data/vendor/mthaml/mthaml/test/MtHaml/Tests/Parser/BufferTest.php +77 -0
  220. data/vendor/mthaml/mthaml/test/MtHaml/Tests/ParserTest.php +47 -0
  221. data/vendor/mthaml/mthaml/test/MtHaml/Tests/RuntimeTest.php +356 -0
  222. data/vendor/mthaml/mthaml/test/MtHaml/Tests/Support/Php/ExecutorTest.php +83 -0
  223. data/vendor/mthaml/mthaml/test/MtHaml/Tests/Support/Twig/LoaderTest.php +65 -0
  224. data/vendor/mthaml/mthaml/test/MtHaml/Tests/TestCase.php +49 -0
  225. data/vendor/mthaml/mthaml/test/MtHaml/Tests/TestCaseTest.php +50 -0
  226. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/Support/Php/Executor.001.haml +1 -0
  227. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/attr_list_php.test +20 -0
  228. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/attr_list_twig.test +12 -0
  229. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/boolean_attr_php.test +16 -0
  230. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/boolean_attr_twig.test +16 -0
  231. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug28_php.test +15 -0
  232. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug28_twig.test +15 -0
  233. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug42.test +13 -0
  234. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug8_twig.test +10 -0
  235. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/coffeescript_filter.test +31 -0
  236. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/comments.test +26 -0
  237. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/cond_cmt.test +25 -0
  238. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype.test +18 -0
  239. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_html4.test +20 -0
  240. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_invalid.test +12 -0
  241. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_invalid_xhtml.test +12 -0
  242. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_php.test +18 -0
  243. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_xhtml.test +30 -0
  244. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/filters.test +51 -0
  245. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/insert_non_echo_php.test +11 -0
  246. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/insert_non_echo_twig.test +11 -0
  247. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/interpolation_in_html_attrs_php.test +31 -0
  248. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/interpolation_in_html_attrs_twig.test +31 -0
  249. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/less_filter_leafo.test +33 -0
  250. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/less_filter_oyejorge.test +49 -0
  251. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_cebemarkdown.test +35 -0
  252. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_ciconia.test +36 -0
  253. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_michelf.test +34 -0
  254. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_parsedown.test +31 -0
  255. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_optimization_filter_michelf.test +23 -0
  256. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/mergeattrs.test +18 -0
  257. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/nuke_inner_whitespace.test +77 -0
  258. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/nuke_outer_whitespace.test +122 -0
  259. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/object_ref_php.test +14 -0
  260. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/object_ref_twig.test +14 -0
  261. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php.test +109 -0
  262. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_autoescaping.test +22 -0
  263. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_autoescaping_once.test +25 -0
  264. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_blocks.test +29 -0
  265. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_filters.test +42 -0
  266. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/scss_filter.test +32 -0
  267. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/strip_inline_comments_php.test +22 -0
  268. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/test.test +24 -0
  269. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/trailing_semicolon_php.test +14 -0
  270. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/try_catch_php.test +17 -0
  271. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig.test +112 -0
  272. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig_blocks.test +29 -0
  273. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig_filters.test +37 -0
  274. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig_whitespace.test +32 -0
  275. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/whitespace.test +63 -0
  276. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/autoclose.test +30 -0
  277. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/escaping.test +52 -0
  278. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/escaping_attr_once.test +52 -0
  279. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/escaping_html_false.test +52 -0
  280. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/mergeattrs.test +26 -0
  281. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/midblock.test +54 -0
  282. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/midblock_002.test +32 -0
  283. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attr_list.test +14 -0
  284. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs.test +42 -0
  285. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs_002.test +35 -0
  286. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs_003.test +30 -0
  287. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs_html_linebreak.test +17 -0
  288. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/blocks.test +27 -0
  289. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/blocks_002.test +15 -0
  290. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/boolean_attr.test +19 -0
  291. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/bug28.test +15 -0
  292. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/bug8.test +11 -0
  293. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/cond_cmt.test +23 -0
  294. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/doctype.test +11 -0
  295. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/double_equal.test +7 -0
  296. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/empty_line_after_multiline.test +10 -0
  297. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_001.test +8 -0
  298. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_002.test +8 -0
  299. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_003.test +8 -0
  300. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_004.test +6 -0
  301. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_005.test +5 -0
  302. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_006.test +7 -0
  303. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_007.test +7 -0
  304. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_008.test +7 -0
  305. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_009.test +5 -0
  306. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_010.test +5 -0
  307. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_013.test +5 -0
  308. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_016.test +7 -0
  309. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_017.test +8 -0
  310. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_018.test +6 -0
  311. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_019.test +6 -0
  312. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_020.test +5 -0
  313. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters.test +20 -0
  314. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_002.test +19 -0
  315. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_003.test +13 -0
  316. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_004.test +21 -0
  317. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_005.test +22 -0
  318. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_006.test +23 -0
  319. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/insertflags.test +17 -0
  320. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/interpolation.test +36 -0
  321. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/interpolation_in_html_attrs.test +17 -0
  322. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/multiline.test +18 -0
  323. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/multiline_code.test +59 -0
  324. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/multiple_attr_kinds.test +47 -0
  325. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/non_rendered_comment.test +31 -0
  326. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ns.test +11 -0
  327. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/object_ref.test +22 -0
  328. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/object_ref_error1.test +5 -0
  329. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/object_ref_error2.test +5 -0
  330. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/quotes_in_haml.test +10 -0
  331. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby19_attrs.test +11 -0
  332. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma.test +23 -0
  333. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma_errors_001.test +5 -0
  334. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma_errors_002.test +5 -0
  335. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma_errors_003.test +5 -0
  336. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/standard.test +114 -0
  337. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/tagflags.test +39 -0
  338. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/runtime/php_filters.test +28 -0
  339. data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/runtime/twig_filters.test +31 -0
  340. data/vendor/mthaml/mthaml/test/bootstrap.php +3 -0
  341. metadata +398 -0
@@ -0,0 +1,207 @@
1
+ # Comments
2
+ # --------
3
+
4
+ # * Single-Line Comments
5
+ # * Block Comments
6
+
7
+ # Note: awkward spacing seen in some tests is likely intentional.
8
+
9
+ test "comments in objects", ->
10
+ obj1 = {
11
+ # comment
12
+ # comment
13
+ # comment
14
+ one: 1
15
+ # comment
16
+ two: 2
17
+ # comment
18
+ }
19
+
20
+ ok Object::hasOwnProperty.call(obj1,'one')
21
+ eq obj1.one, 1
22
+ ok Object::hasOwnProperty.call(obj1,'two')
23
+ eq obj1.two, 2
24
+
25
+ test "comments in YAML-style objects", ->
26
+ obj2 =
27
+ # comment
28
+ # comment
29
+ # comment
30
+ three: 3
31
+ # comment
32
+ four: 4
33
+ # comment
34
+
35
+ ok Object::hasOwnProperty.call(obj2,'three')
36
+ eq obj2.three, 3
37
+ ok Object::hasOwnProperty.call(obj2,'four')
38
+ eq obj2.four, 4
39
+
40
+ test "comments following operators that continue lines", ->
41
+ sum =
42
+ 1 +
43
+ 1 + # comment
44
+ 1
45
+ eq 3, sum
46
+
47
+ test "comments in functions", ->
48
+ fn = ->
49
+ # comment
50
+ false
51
+ false # comment
52
+ false
53
+ # comment
54
+
55
+ # comment
56
+ true
57
+
58
+ ok fn()
59
+
60
+ fn2 = -> #comment
61
+ fn()
62
+ # comment
63
+
64
+ ok fn2()
65
+
66
+ test "trailing comment before an outdent", ->
67
+ nonce = {}
68
+ fn3 = ->
69
+ if true
70
+ undefined # comment
71
+ nonce
72
+
73
+ eq nonce, fn3()
74
+
75
+ test "comments in a switch", ->
76
+ nonce = {}
77
+ result = switch nonce #comment
78
+ # comment
79
+ when false then undefined
80
+ # comment
81
+ when null #comment
82
+ undefined
83
+ else nonce # comment
84
+
85
+ eq nonce, result
86
+
87
+ test "comment with conditional statements", ->
88
+ nonce = {}
89
+ result = if false # comment
90
+ undefined
91
+ #comment
92
+ else # comment
93
+ nonce
94
+ # comment
95
+ eq nonce, result
96
+
97
+ test "spaced comments with conditional statements", ->
98
+ nonce = {}
99
+ result = if false
100
+ undefined
101
+
102
+ # comment
103
+ else if false
104
+ undefined
105
+
106
+ # comment
107
+ else
108
+ nonce
109
+
110
+ eq nonce, result
111
+
112
+
113
+ # Block Comments
114
+
115
+ ###
116
+ This is a here-comment.
117
+ Kind of like a heredoc.
118
+ ###
119
+
120
+ test "block comments in objects", ->
121
+ a = {}
122
+ b = {}
123
+ obj = {
124
+ a: a
125
+ ###
126
+ comment
127
+ ###
128
+ b: b
129
+ }
130
+
131
+ eq a, obj.a
132
+ eq b, obj.b
133
+
134
+ test "block comments in YAML-style", ->
135
+ a = {}
136
+ b = {}
137
+ obj =
138
+ a: a
139
+ ###
140
+ comment
141
+ ###
142
+ b: b
143
+
144
+ eq a, obj.a
145
+ eq b, obj.b
146
+
147
+
148
+ test "block comments in functions", ->
149
+ nonce = {}
150
+
151
+ fn1 = ->
152
+ true
153
+ ###
154
+ false
155
+ ###
156
+
157
+ ok fn1()
158
+
159
+ fn2 = ->
160
+ ###
161
+ block comment
162
+ ###
163
+ nonce
164
+
165
+ eq nonce, fn2()
166
+
167
+ fn3 = ->
168
+ nonce
169
+ ###
170
+ block comment
171
+ ###
172
+
173
+ eq nonce, fn3()
174
+
175
+ fn4 = ->
176
+ one = ->
177
+ ###
178
+ block comment
179
+ ###
180
+ two = ->
181
+ three = ->
182
+ nonce
183
+
184
+ eq nonce, fn4()()()()
185
+
186
+ test "block comments inside class bodies", ->
187
+ class A
188
+ a: ->
189
+
190
+ ###
191
+ Comment
192
+ ###
193
+ b: ->
194
+
195
+ ok A.prototype.b instanceof Function
196
+
197
+ class B
198
+ ###
199
+ Comment
200
+ ###
201
+ a: ->
202
+ b: ->
203
+
204
+ ok B.prototype.a instanceof Function
205
+
206
+ test "#2037: herecomments shouldn't imply line terminators", ->
207
+ do (-> ### ###; fail)
@@ -0,0 +1,72 @@
1
+ # Compilation
2
+ # -----------
3
+
4
+ # helper to assert that a string should fail compilation
5
+ cantCompile = (code) ->
6
+ throws -> CoffeeScript.compile code
7
+
8
+
9
+ test "ensure that carriage returns don't break compilation on Windows", ->
10
+ doesNotThrow -> CoffeeScript.compile 'one\r\ntwo', bare: on
11
+
12
+ test "--bare", ->
13
+ eq -1, CoffeeScript.compile('x = y', bare: on).indexOf 'function'
14
+ ok 'passed' is CoffeeScript.eval '"passed"', bare: on, filename: 'test'
15
+
16
+ test "header (#1778)", ->
17
+ header = "// Generated by CoffeeScript #{CoffeeScript.VERSION}\n"
18
+ eq 0, CoffeeScript.compile('x = y', header: on).indexOf header
19
+
20
+ test "header is disabled by default", ->
21
+ header = "// Generated by CoffeeScript #{CoffeeScript.VERSION}\n"
22
+ eq -1, CoffeeScript.compile('x = y').indexOf header
23
+
24
+ test "multiple generated references", ->
25
+ a = {b: []}
26
+ a.b[true] = -> this == a.b
27
+ c = 0
28
+ d = []
29
+ ok a.b[0<++c<2] d...
30
+
31
+ test "splat on a line by itself is invalid", ->
32
+ cantCompile "x 'a'\n...\n"
33
+
34
+ test "Issue 750", ->
35
+
36
+ cantCompile 'f(->'
37
+
38
+ cantCompile 'a = (break)'
39
+
40
+ cantCompile 'a = (return 5 for item in list)'
41
+
42
+ cantCompile 'a = (return 5 while condition)'
43
+
44
+ cantCompile 'a = for x in y\n return 5'
45
+
46
+ test "Issue #986: Unicode identifiers", ->
47
+ λ = 5
48
+ eq λ, 5
49
+
50
+ test "don't accidentally stringify keywords", ->
51
+ ok (-> this == 'this')() is false
52
+
53
+ test "#1026", ->
54
+ cantCompile '''
55
+ if a
56
+ b
57
+ else
58
+ c
59
+ else
60
+ d
61
+ '''
62
+
63
+ test "#1050", ->
64
+ cantCompile "### */ ###"
65
+
66
+ test "#1106: __proto__ compilation", ->
67
+ object = eq
68
+ @["__proto__"] = true
69
+ ok __proto__
70
+
71
+ test "reference named hasOwnProperty", ->
72
+ CoffeeScript.compile 'hasOwnProperty = 0; a = 1'
@@ -0,0 +1,501 @@
1
+ # Comprehensions
2
+ # --------------
3
+
4
+ # * Array Comprehensions
5
+ # * Range Comprehensions
6
+ # * Object Comprehensions
7
+ # * Implicit Destructuring Assignment
8
+ # * Comprehensions with Nonstandard Step
9
+
10
+ # TODO: refactor comprehension tests
11
+
12
+ test "Basic array comprehensions.", ->
13
+
14
+ nums = (n * n for n in [1, 2, 3] when n & 1)
15
+ results = (n * 2 for n in nums)
16
+
17
+ ok results.join(',') is '2,18'
18
+
19
+
20
+ test "Basic object comprehensions.", ->
21
+
22
+ obj = {one: 1, two: 2, three: 3}
23
+ names = (prop + '!' for prop of obj)
24
+ odds = (prop + '!' for prop, value of obj when value & 1)
25
+
26
+ ok names.join(' ') is "one! two! three!"
27
+ ok odds.join(' ') is "one! three!"
28
+
29
+
30
+ test "Basic range comprehensions.", ->
31
+
32
+ nums = (i * 3 for i in [1..3])
33
+
34
+ negs = (x for x in [-20..-5*2])
35
+ negs = negs[0..2]
36
+
37
+ result = nums.concat(negs).join(', ')
38
+
39
+ ok result is '3, 6, 9, -20, -19, -18'
40
+
41
+
42
+ test "With range comprehensions, you can loop in steps.", ->
43
+
44
+ results = (x for x in [0...15] by 5)
45
+ ok results.join(' ') is '0 5 10'
46
+
47
+ results = (x for x in [0..100] by 10)
48
+ ok results.join(' ') is '0 10 20 30 40 50 60 70 80 90 100'
49
+
50
+
51
+ test "And can loop downwards, with a negative step.", ->
52
+
53
+ results = (x for x in [5..1])
54
+
55
+ ok results.join(' ') is '5 4 3 2 1'
56
+ ok results.join(' ') is [(10-5)..(-2+3)].join(' ')
57
+
58
+ results = (x for x in [10..1])
59
+ ok results.join(' ') is [10..1].join(' ')
60
+
61
+ results = (x for x in [10...0] by -2)
62
+ ok results.join(' ') is [10, 8, 6, 4, 2].join(' ')
63
+
64
+
65
+ test "Range comprehension gymnastics.", ->
66
+
67
+ eq "#{i for i in [5..1]}", '5,4,3,2,1'
68
+ eq "#{i for i in [5..-5] by -5}", '5,0,-5'
69
+
70
+ a = 6
71
+ b = 0
72
+ c = -2
73
+
74
+ eq "#{i for i in [a..b]}", '6,5,4,3,2,1,0'
75
+ eq "#{i for i in [a..b] by c}", '6,4,2,0'
76
+
77
+
78
+ test "Multiline array comprehension with filter.", ->
79
+
80
+ evens = for num in [1, 2, 3, 4, 5, 6] when not (num & 1)
81
+ num *= -1
82
+ num -= 2
83
+ num * -1
84
+ eq evens + '', '4,6,8'
85
+
86
+
87
+ test "The in operator still works, standalone.", ->
88
+
89
+ ok 2 of evens
90
+
91
+
92
+ test "all isn't reserved.", ->
93
+
94
+ all = 1
95
+
96
+
97
+ test "Ensure that the closure wrapper preserves local variables.", ->
98
+
99
+ obj = {}
100
+
101
+ for method in ['one', 'two', 'three'] then do (method) ->
102
+ obj[method] = ->
103
+ "I'm " + method
104
+
105
+ ok obj.one() is "I'm one"
106
+ ok obj.two() is "I'm two"
107
+ ok obj.three() is "I'm three"
108
+
109
+
110
+ test "Index values at the end of a loop.", ->
111
+
112
+ i = 0
113
+ for i in [1..3]
114
+ -> 'func'
115
+ break if false
116
+ ok i is 4
117
+
118
+
119
+ test "Ensure that local variables are closed over for range comprehensions.", ->
120
+
121
+ funcs = for i in [1..3]
122
+ do (i) ->
123
+ -> -i
124
+
125
+ eq (func() for func in funcs).join(' '), '-1 -2 -3'
126
+ ok i is 4
127
+
128
+
129
+ test "Even when referenced in the filter.", ->
130
+
131
+ list = ['one', 'two', 'three']
132
+
133
+ methods = for num, i in list when num isnt 'two' and i isnt 1
134
+ do (num, i) ->
135
+ -> num + ' ' + i
136
+
137
+ ok methods.length is 2
138
+ ok methods[0]() is 'one 0'
139
+ ok methods[1]() is 'three 2'
140
+
141
+
142
+ test "Even a convoluted one.", ->
143
+
144
+ funcs = []
145
+
146
+ for i in [1..3]
147
+ do (i) ->
148
+ x = i * 2
149
+ ((z)->
150
+ funcs.push -> z + ' ' + i
151
+ )(x)
152
+
153
+ ok (func() for func in funcs).join(', ') is '2 1, 4 2, 6 3'
154
+
155
+ funcs = []
156
+
157
+ results = for i in [1..3]
158
+ do (i) ->
159
+ z = (x * 3 for x in [1..i])
160
+ ((a, b, c) -> [a, b, c].join(' ')).apply this, z
161
+
162
+ ok results.join(', ') is '3 , 3 6 , 3 6 9'
163
+
164
+
165
+ test "Naked ranges are expanded into arrays.", ->
166
+
167
+ array = [0..10]
168
+ ok(num % 2 is 0 for num in array by 2)
169
+
170
+
171
+ test "Nested shared scopes.", ->
172
+
173
+ foo = ->
174
+ for i in [0..7]
175
+ do (i) ->
176
+ for j in [0..7]
177
+ do (j) ->
178
+ -> i + j
179
+
180
+ eq foo()[3][4](), 7
181
+
182
+
183
+ test "Scoped loop pattern matching.", ->
184
+
185
+ a = [[0], [1]]
186
+ funcs = []
187
+
188
+ for [v] in a
189
+ do (v) ->
190
+ funcs.push -> v
191
+
192
+ eq funcs[0](), 0
193
+ eq funcs[1](), 1
194
+
195
+
196
+ test "Nested comprehensions.", ->
197
+
198
+ multiLiner =
199
+ for x in [3..5]
200
+ for y in [3..5]
201
+ [x, y]
202
+
203
+ singleLiner =
204
+ (([x, y] for y in [3..5]) for x in [3..5])
205
+
206
+ ok multiLiner.length is singleLiner.length
207
+ ok 5 is multiLiner[2][2][1]
208
+ ok 5 is singleLiner[2][2][1]
209
+
210
+
211
+ test "Comprehensions within parentheses.", ->
212
+
213
+ result = null
214
+ store = (obj) -> result = obj
215
+ store (x * 2 for x in [3, 2, 1])
216
+
217
+ ok result.join(' ') is '6 4 2'
218
+
219
+
220
+ test "Closure-wrapped comprehensions that refer to the 'arguments' object.", ->
221
+
222
+ expr = ->
223
+ result = (item * item for item in arguments)
224
+
225
+ ok expr(2, 4, 8).join(' ') is '4 16 64'
226
+
227
+
228
+ test "Fast object comprehensions over all properties, including prototypal ones.", ->
229
+
230
+ class Cat
231
+ constructor: -> @name = 'Whiskers'
232
+ breed: 'tabby'
233
+ hair: 'cream'
234
+
235
+ whiskers = new Cat
236
+ own = (value for own key, value of whiskers)
237
+ all = (value for key, value of whiskers)
238
+
239
+ ok own.join(' ') is 'Whiskers'
240
+ ok all.sort().join(' ') is 'Whiskers cream tabby'
241
+
242
+
243
+ test "Optimized range comprehensions.", ->
244
+
245
+ exxes = ('x' for [0...10])
246
+ ok exxes.join(' ') is 'x x x x x x x x x x'
247
+
248
+
249
+ test "Comprehensions safely redeclare parameters if they're not present in closest scope.", ->
250
+
251
+ rule = (x) -> x
252
+
253
+ learn = ->
254
+ rule for rule in [1, 2, 3]
255
+
256
+ ok learn().join(' ') is '1 2 3'
257
+
258
+ ok rule(101) is 101
259
+
260
+ f = -> [-> ok no, 'should cache source']
261
+ ok yes for k of [f] = f()
262
+
263
+
264
+ test "Lenient on pure statements not trying to reach out of the closure", ->
265
+
266
+ val = for i in [1]
267
+ for j in [] then break
268
+ i
269
+ ok val[0] is i
270
+
271
+
272
+ test "Comprehensions only wrap their last line in a closure, allowing other lines
273
+ to have pure expressions in them.", ->
274
+
275
+ func = -> for i in [1]
276
+ break if i is 2
277
+ j for j in [1]
278
+
279
+ ok func()[0][0] is 1
280
+
281
+ i = 6
282
+ odds = while i--
283
+ continue unless i & 1
284
+ i
285
+
286
+ ok odds.join(', ') is '5, 3, 1'
287
+
288
+
289
+ test "Issue #897: Ensure that plucked function variables aren't leaked.", ->
290
+
291
+ facets = {}
292
+ list = ['one', 'two']
293
+
294
+ (->
295
+ for entity in list
296
+ facets[entity] = -> entity
297
+ )()
298
+
299
+ eq typeof entity, 'undefined'
300
+ eq facets['two'](), 'two'
301
+
302
+
303
+ test "Issue #905. Soaks as the for loop subject.", ->
304
+
305
+ a = {b: {c: [1, 2, 3]}}
306
+ for d in a.b?.c
307
+ e = d
308
+
309
+ eq e, 3
310
+
311
+
312
+ test "Issue #948. Capturing loop variables.", ->
313
+
314
+ funcs = []
315
+ list = ->
316
+ [1, 2, 3]
317
+
318
+ for y in list()
319
+ do (y) ->
320
+ z = y
321
+ funcs.push -> "y is #{y} and z is #{z}"
322
+
323
+ eq funcs[1](), "y is 2 and z is 2"
324
+
325
+
326
+ test "Cancel the comprehension if there's a jump inside the loop.", ->
327
+
328
+ result = try
329
+ for i in [0...10]
330
+ continue if i < 5
331
+ i
332
+
333
+ eq result, 10
334
+
335
+
336
+ test "Comprehensions over break.", ->
337
+
338
+ arrayEq (break for [1..10]), []
339
+
340
+
341
+ test "Comprehensions over continue.", ->
342
+
343
+ arrayEq (continue for [1..10]), []
344
+
345
+
346
+ test "Comprehensions over function literals.", ->
347
+
348
+ a = 0
349
+ for f in [-> a = 1]
350
+ do (f) ->
351
+ do f
352
+
353
+ eq a, 1
354
+
355
+
356
+ test "Comprehensions that mention arguments.", ->
357
+
358
+ list = [arguments: 10]
359
+ args = for f in list
360
+ do (f) ->
361
+ f.arguments
362
+ eq args[0], 10
363
+
364
+
365
+ test "expression conversion under explicit returns", ->
366
+ nonce = {}
367
+ fn = ->
368
+ return (nonce for x in [1,2,3])
369
+ arrayEq [nonce,nonce,nonce], fn()
370
+ fn = ->
371
+ return [nonce for x in [1,2,3]][0]
372
+ arrayEq [nonce,nonce,nonce], fn()
373
+ fn = ->
374
+ return [(nonce for x in [1..3])][0]
375
+ arrayEq [nonce,nonce,nonce], fn()
376
+
377
+
378
+ test "implicit destructuring assignment in object of objects", ->
379
+ a={}; b={}; c={}
380
+ obj = {
381
+ a: { d: a },
382
+ b: { d: b }
383
+ c: { d: c }
384
+ }
385
+ result = ([y,z] for y, { d: z } of obj)
386
+ arrayEq [['a',a],['b',b],['c',c]], result
387
+
388
+
389
+ test "implicit destructuring assignment in array of objects", ->
390
+ a={}; b={}; c={}; d={}; e={}; f={}
391
+ arr = [
392
+ { a: a, b: { c: b } },
393
+ { a: c, b: { c: d } },
394
+ { a: e, b: { c: f } }
395
+ ]
396
+ result = ([y,z] for { a: y, b: { c: z } } in arr)
397
+ arrayEq [[a,b],[c,d],[e,f]], result
398
+
399
+
400
+ test "implicit destructuring assignment in array of arrays", ->
401
+ a={}; b={}; c={}; d={}; e={}; f={}
402
+ arr = [[a, [b]], [c, [d]], [e, [f]]]
403
+ result = ([y,z] for [y, [z]] in arr)
404
+ arrayEq [[a,b],[c,d],[e,f]], result
405
+
406
+ test "issue #1124: don't assign a variable in two scopes", ->
407
+ lista = [1, 2, 3, 4, 5]
408
+ listb = (_i + 1 for _i in lista)
409
+ arrayEq [2, 3, 4, 5, 6], listb
410
+
411
+ test "#1326: `by` value is uncached", ->
412
+ a = [0,1,2]
413
+ fi = gi = hi = 0
414
+ f = -> ++fi
415
+ g = -> ++gi
416
+ h = -> ++hi
417
+
418
+ forCompile = []
419
+ rangeCompileSimple = []
420
+
421
+ #exercises For.compile
422
+ for v,i in a by f() then forCompile.push i
423
+
424
+ #exercises Range.compileSimple
425
+ rangeCompileSimple = (i for i in [0..2] by g())
426
+
427
+ arrayEq a, forCompile
428
+ arrayEq a, rangeCompileSimple
429
+ #exercises Range.compile
430
+ eq "#{i for i in [0..2] by h()}", '0,1,2'
431
+
432
+ test "#1669: break/continue should skip the result only for that branch", ->
433
+ ns = for n in [0..99]
434
+ if n > 9
435
+ break
436
+ else if n & 1
437
+ continue
438
+ else
439
+ n
440
+ eq "#{ns}", '0,2,4,6,8'
441
+
442
+ # `else undefined` is implied.
443
+ ns = for n in [1..9]
444
+ if n % 2
445
+ continue unless n % 5
446
+ n
447
+ eq "#{ns}", "1,,3,,,7,,9"
448
+
449
+ # Ditto.
450
+ ns = for n in [1..9]
451
+ switch
452
+ when n % 2
453
+ continue unless n % 5
454
+ n
455
+ eq "#{ns}", "1,,3,,,7,,9"
456
+
457
+ test "#1850: inner `for` should not be expression-ized if `return`ing", ->
458
+ eq '3,4,5', do ->
459
+ for a in [1..9] then \
460
+ for b in [1..9]
461
+ c = Math.sqrt a*a + b*b
462
+ return String [a, b, c] unless c % 1
463
+
464
+ test "#1910: loop index should be mutable within a loop iteration and immutable between loop iterations", ->
465
+ n = 1
466
+ iterations = 0
467
+ arr = [0..n]
468
+ for v, k in arr
469
+ ++iterations
470
+ v = k = 5
471
+ eq 5, k
472
+ eq 2, k
473
+ eq 2, iterations
474
+
475
+ iterations = 0
476
+ for v in [0..n]
477
+ ++iterations
478
+ eq 2, k
479
+ eq 2, iterations
480
+
481
+ arr = ([v, v + 1] for v in [0..5])
482
+ iterations = 0
483
+ for own [v0, v1], k in arr when v0
484
+ k += 3
485
+ ++iterations
486
+ eq 6, k
487
+ eq 5, iterations
488
+
489
+ test "#2007: Return object literal from comprehension", ->
490
+ y = for x in [1, 2]
491
+ foo: "foo" + x
492
+ eq 2, y.length
493
+ eq "foo1", y[0].foo
494
+ eq "foo2", y[1].foo
495
+
496
+ x = 2
497
+ y = while x
498
+ x: --x
499
+ eq 2, y.length
500
+ eq 1, y[0].x
501
+ eq 0, y[1].x