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,102 @@
1
+ # Exception Handling
2
+ # ------------------
3
+
4
+ # shared nonce
5
+ nonce = {}
6
+
7
+
8
+ # Throw
9
+
10
+ test "basic exception throwing", ->
11
+ throws (-> throw 'error'), 'error'
12
+
13
+
14
+ # Empty Try/Catch/Finally
15
+
16
+ test "try can exist alone", ->
17
+ try
18
+
19
+ test "try/catch with empty try, empty catch", ->
20
+ try
21
+ # nothing
22
+ catch err
23
+ # nothing
24
+
25
+ test "single-line try/catch with empty try, empty catch", ->
26
+ try catch err
27
+
28
+ test "try/finally with empty try, empty finally", ->
29
+ try
30
+ # nothing
31
+ finally
32
+ # nothing
33
+
34
+ test "single-line try/finally with empty try, empty finally", ->
35
+ try finally
36
+
37
+ test "try/catch/finally with empty try, empty catch, empty finally", ->
38
+ try
39
+ catch err
40
+ finally
41
+
42
+ test "single-line try/catch/finally with empty try, empty catch, empty finally", ->
43
+ try catch err then finally
44
+
45
+
46
+ # Try/Catch/Finally as an Expression
47
+
48
+ test "return the result of try when no exception is thrown", ->
49
+ result = try
50
+ nonce
51
+ catch err
52
+ undefined
53
+ finally
54
+ undefined
55
+ eq nonce, result
56
+
57
+ test "single-line result of try when no exception is thrown", ->
58
+ result = try nonce catch err then undefined
59
+ eq nonce, result
60
+
61
+ test "return the result of catch when an exception is thrown", ->
62
+ fn = ->
63
+ try
64
+ throw ->
65
+ catch err
66
+ nonce
67
+ doesNotThrow fn
68
+ eq nonce, fn()
69
+
70
+ test "single-line result of catch when an exception is thrown", ->
71
+ fn = ->
72
+ try throw (->) catch err then nonce
73
+ doesNotThrow fn
74
+ eq nonce, fn()
75
+
76
+ test "optional catch", ->
77
+ fn = ->
78
+ try throw ->
79
+ nonce
80
+ doesNotThrow fn
81
+ eq nonce, fn()
82
+
83
+
84
+ # Try/Catch/Finally Interaction With Other Constructs
85
+
86
+ test "try/catch with empty catch as last statement in a function body", ->
87
+ fn = ->
88
+ try nonce
89
+ catch err
90
+ eq nonce, fn()
91
+
92
+
93
+ # Catch leads to broken scoping: #1595
94
+
95
+ test "try/catch with a reused variable name.", ->
96
+ do ->
97
+ try
98
+ inner = 5
99
+ catch inner
100
+ # nothing
101
+ eq typeof inner, 'undefined'
102
+
@@ -0,0 +1,146 @@
1
+ # Formatting
2
+ # ----------
3
+
4
+ # TODO: maybe this file should be split up into their respective sections:
5
+ # operators -> operators
6
+ # array literals -> array literals
7
+ # string literals -> string literals
8
+ # function invocations -> function invocations
9
+
10
+ # * Line Continuation
11
+ # * Property Accesss
12
+ # * Operators
13
+ # * Array Literals
14
+ # * Function Invocations
15
+ # * String Literals
16
+
17
+ doesNotThrow -> CoffeeScript.compile "a = then b"
18
+
19
+ test "multiple semicolon-separated statements in parentheticals", ->
20
+ nonce = {}
21
+ eq nonce, (1; 2; nonce)
22
+ eq nonce, (-> return (1; 2; nonce))()
23
+
24
+ # Line Continuation
25
+
26
+ # Property Access
27
+
28
+ test "chained accesses split on period/newline, backwards and forwards", ->
29
+ str = 'abc'
30
+ result = str.
31
+ split('').
32
+ reverse().
33
+ reverse().
34
+ reverse()
35
+ arrayEq ['c','b','a'], result
36
+ arrayEq ['c','b','a'], str.
37
+ split('').
38
+ reverse().
39
+ reverse().
40
+ reverse()
41
+ result = str
42
+ .split('')
43
+ .reverse()
44
+ .reverse()
45
+ .reverse()
46
+ arrayEq ['c','b','a'], result
47
+ arrayEq ['c','b','a'], str
48
+ .split('')
49
+ .reverse()
50
+ .reverse()
51
+ .reverse()
52
+ arrayEq ['c','b','a'], str.
53
+ split('')
54
+ .reverse().
55
+ reverse()
56
+ .reverse()
57
+
58
+ # Operators
59
+
60
+ test "newline suppression for operators", ->
61
+ six =
62
+ 1 +
63
+ 2 +
64
+ 3
65
+ eq 6, six
66
+
67
+ test "`?.` and `::` should continue lines", ->
68
+ ok not Date
69
+ ::
70
+ ?.foo
71
+ #eq Object::toString, Date?.
72
+ #prototype
73
+ #::
74
+ #?.foo
75
+
76
+ doesNotThrow -> CoffeeScript.compile """
77
+ oh. yes
78
+ oh?. true
79
+ oh:: return
80
+ """
81
+
82
+ doesNotThrow -> CoffeeScript.compile """
83
+ a?[b..]
84
+ a?[...b]
85
+ a?[b..c]
86
+ """
87
+
88
+ # Array Literals
89
+
90
+ test "indented array literals don't trigger whitespace rewriting", ->
91
+ getArgs = -> arguments
92
+ result = getArgs(
93
+ [[[[[],
94
+ []],
95
+ [[]]]],
96
+ []])
97
+ eq 1, result.length
98
+
99
+ # Function Invocations
100
+
101
+ doesNotThrow -> CoffeeScript.compile """
102
+ obj = then fn 1,
103
+ 1: 1
104
+ a:
105
+ b: ->
106
+ fn c,
107
+ d: e
108
+ f: 1
109
+ """
110
+
111
+ # String Literals
112
+
113
+ test "indented heredoc", ->
114
+ result = ((_) -> _)(
115
+ """
116
+ abc
117
+ """)
118
+ eq "abc", result
119
+
120
+ # Nested blocks caused by paren unwrapping
121
+ test "#1492: Nested blocks don't cause double semicolons", ->
122
+ js = CoffeeScript.compile '(0;0)'
123
+ eq -1, js.indexOf ';;'
124
+
125
+ test "#1195 Ignore trailing semicolons (before newlines or as the last char in a program)", ->
126
+ preNewline = (numSemicolons) ->
127
+ """
128
+ nonce = {}; nonce2 = {}
129
+ f = -> nonce#{Array(numSemicolons+1).join(';')}
130
+ nonce2
131
+ unless f() is nonce then throw new Error('; before linebreak should = newline')
132
+ """
133
+ CoffeeScript.run(preNewline(n), bare: true) for n in [1,2,3]
134
+
135
+ lastChar = '-> lastChar;'
136
+ doesNotThrow -> CoffeeScript.compile lastChar, bare: true
137
+
138
+ test "#1299: Disallow token misnesting", ->
139
+ try
140
+ CoffeeScript.compile '''
141
+ [{
142
+ ]}
143
+ '''
144
+ ok no
145
+ catch e
146
+ eq 'unmatched ] on line 2', e.message
@@ -0,0 +1,552 @@
1
+ # Function Invocation
2
+ # -------------------
3
+
4
+ # * Function Invocation
5
+ # * Splats in Function Invocations
6
+ # * Implicit Returns
7
+ # * Explicit Returns
8
+
9
+ # shared identity function
10
+ id = (_) -> if arguments.length is 1 then _ else [arguments...]
11
+
12
+
13
+ test "basic argument passing", ->
14
+
15
+ a = {}
16
+ b = {}
17
+ c = {}
18
+ eq 1, (id 1)
19
+ eq 2, (id 1, 2)[1]
20
+ eq a, (id a)
21
+ eq c, (id a, b, c)[2]
22
+
23
+
24
+ test "passing arguments on separate lines", ->
25
+
26
+ a = {}
27
+ b = {}
28
+ c = {}
29
+ ok(id(
30
+ a
31
+ b
32
+ c
33
+ )[1] is b)
34
+ eq(0, id(
35
+ 0
36
+ 10
37
+ )[0])
38
+ eq(a,id(
39
+ a
40
+ ))
41
+ eq b,
42
+ (id b)
43
+
44
+
45
+ test "optional parens can be used in a nested fashion", ->
46
+
47
+ call = (func) -> func()
48
+ add = (a,b) -> a + b
49
+ result = call ->
50
+ inner = call ->
51
+ add 5, 5
52
+ ok result is 10
53
+
54
+
55
+ test "hanging commas and semicolons in argument list", ->
56
+
57
+ fn = () -> arguments.length
58
+ eq 2, fn(0,1,)
59
+ eq 3, fn 0, 1,
60
+ 2
61
+ eq 2, fn(0, 1;)
62
+ # TODO: this test fails (the string compiles), but should it?
63
+ #throws -> CoffeeScript.compile "fn(0,1,;)"
64
+ throws -> CoffeeScript.compile "fn(0,1,;;)"
65
+ throws -> CoffeeScript.compile "fn(0, 1;,)"
66
+ throws -> CoffeeScript.compile "fn(,0)"
67
+ throws -> CoffeeScript.compile "fn(;0)"
68
+
69
+
70
+ test "function invocation", ->
71
+
72
+ func = ->
73
+ return if true
74
+ eq undefined, func()
75
+
76
+ result = ("hello".slice) 3
77
+ ok result is 'lo'
78
+
79
+
80
+ test "And even with strange things like this:", ->
81
+
82
+ funcs = [((x) -> x), ((x) -> x * x)]
83
+ result = funcs[1] 5
84
+ ok result is 25
85
+
86
+
87
+ test "More fun with optional parens.", ->
88
+
89
+ fn = (arg) -> arg
90
+ ok fn(fn {prop: 101}).prop is 101
91
+
92
+ okFunc = (f) -> ok(f())
93
+ okFunc -> true
94
+
95
+
96
+ test "chained function calls", ->
97
+ nonce = {}
98
+ identityWrap = (x) ->
99
+ -> x
100
+ eq nonce, identityWrap(identityWrap(nonce))()()
101
+ eq nonce, (identityWrap identityWrap nonce)()()
102
+
103
+
104
+ test "Multi-blocks with optional parens.", ->
105
+
106
+ fn = (arg) -> arg
107
+ result = fn( ->
108
+ fn ->
109
+ "Wrapped"
110
+ )
111
+ ok result()() is 'Wrapped'
112
+
113
+
114
+ test "method calls", ->
115
+
116
+ fnId = (fn) -> -> fn.apply this, arguments
117
+ math = {
118
+ add: (a, b) -> a + b
119
+ anonymousAdd: (a, b) -> a + b
120
+ fastAdd: fnId (a, b) -> a + b
121
+ }
122
+ ok math.add(5, 5) is 10
123
+ ok math.anonymousAdd(10, 10) is 20
124
+ ok math.fastAdd(20, 20) is 40
125
+
126
+
127
+ test "Ensure that functions can have a trailing comma in their argument list", ->
128
+
129
+ mult = (x, mids..., y) ->
130
+ x *= n for n in mids
131
+ x *= y
132
+ ok mult(1, 2,) is 2
133
+ ok mult(1, 2, 3,) is 6
134
+ ok mult(10, (i for i in [1..6])...) is 7200
135
+
136
+
137
+ test "`@` and `this` should both be able to invoke a method", ->
138
+ nonce = {}
139
+ fn = (arg) -> eq nonce, arg
140
+ fn.withAt = -> @ nonce
141
+ fn.withThis = -> this nonce
142
+ fn.withAt()
143
+ fn.withThis()
144
+
145
+
146
+ test "Trying an implicit object call with a trailing function.", ->
147
+
148
+ a = null
149
+ meth = (arg, obj, func) -> a = [obj.a, arg, func()].join ' '
150
+ meth 'apple', b: 1, a: 13, ->
151
+ 'orange'
152
+ ok a is '13 apple orange'
153
+
154
+
155
+ test "Ensure that empty functions don't return mistaken values.", ->
156
+
157
+ obj =
158
+ func: (@param, @rest...) ->
159
+ ok obj.func(101, 102, 103, 104) is undefined
160
+ ok obj.param is 101
161
+ ok obj.rest.join(' ') is '102 103 104'
162
+
163
+
164
+ test "Passing multiple functions without paren-wrapping is legal, and should compile.", ->
165
+
166
+ sum = (one, two) -> one() + two()
167
+ result = sum ->
168
+ 7 + 9
169
+ , ->
170
+ 1 + 3
171
+ ok result is 20
172
+
173
+
174
+ test "Implicit call with a trailing if statement as a param.", ->
175
+
176
+ func = -> arguments[1]
177
+ result = func 'one', if false then 100 else 13
178
+ ok result is 13
179
+
180
+
181
+ test "Test more function passing:", ->
182
+
183
+ sum = (one, two) -> one() + two()
184
+
185
+ result = sum( ->
186
+ 1 + 2
187
+ , ->
188
+ 2 + 1
189
+ )
190
+ ok result is 6
191
+
192
+ sum = (a, b) -> a + b
193
+ result = sum(1
194
+ , 2)
195
+ ok result is 3
196
+
197
+
198
+ test "Chained blocks, with proper indentation levels:", ->
199
+
200
+ counter =
201
+ results: []
202
+ tick: (func) ->
203
+ @results.push func()
204
+ this
205
+ counter
206
+ .tick ->
207
+ 3
208
+ .tick ->
209
+ 2
210
+ .tick ->
211
+ 1
212
+ arrayEq [3,2,1], counter.results
213
+
214
+
215
+ test "This is a crazy one.", ->
216
+
217
+ x = (obj, func) -> func obj
218
+ ident = (x) -> x
219
+ result = x {one: ident 1}, (obj) ->
220
+ inner = ident(obj)
221
+ ident inner
222
+ ok result.one is 1
223
+
224
+
225
+ test "More paren compilation tests:", ->
226
+
227
+ reverse = (obj) -> obj.reverse()
228
+ ok reverse([1, 2].concat 3).join(' ') is '3 2 1'
229
+
230
+
231
+ test "Test for inline functions with parentheses and implicit calls.", ->
232
+
233
+ combine = (func, num) -> func() * num
234
+ result = combine (-> 1 + 2), 3
235
+ ok result is 9
236
+
237
+
238
+ test "Test for calls/parens/multiline-chains.", ->
239
+
240
+ f = (x) -> x
241
+ result = (f 1).toString()
242
+ .length
243
+ ok result is 1
244
+
245
+
246
+ test "Test implicit calls in functions in parens:", ->
247
+
248
+ result = ((val) ->
249
+ [].push val
250
+ val
251
+ )(10)
252
+ ok result is 10
253
+
254
+
255
+ test "Ensure that chained calls with indented implicit object literals below are alright.", ->
256
+
257
+ result = null
258
+ obj =
259
+ method: (val) -> this
260
+ second: (hash) -> result = hash.three
261
+ obj
262
+ .method(
263
+ 101
264
+ ).second(
265
+ one:
266
+ two: 2
267
+ three: 3
268
+ )
269
+ eq result, 3
270
+
271
+
272
+ test "Test newline-supressed call chains with nested functions.", ->
273
+
274
+ obj =
275
+ call: -> this
276
+ func = ->
277
+ obj
278
+ .call ->
279
+ one two
280
+ .call ->
281
+ three four
282
+ 101
283
+ eq func(), 101
284
+
285
+
286
+ test "Implicit objects with number arguments.", ->
287
+
288
+ func = (x, y) -> y
289
+ obj =
290
+ prop: func "a", 1
291
+ ok obj.prop is 1
292
+
293
+
294
+ test "Non-spaced unary and binary operators should cause a function call.", ->
295
+
296
+ func = (val) -> val + 1
297
+ ok (func +5) is 6
298
+ ok (func -5) is -4
299
+
300
+
301
+ test "Prefix unary assignment operators are allowed in parenless calls.", ->
302
+
303
+ func = (val) -> val + 1
304
+ val = 5
305
+ ok (func --val) is 5
306
+
307
+ test "#855: execution context for `func arr...` should be `null`", ->
308
+ contextTest = -> eq @, if window? then window else global
309
+ array = []
310
+ contextTest array
311
+ contextTest.apply null, array
312
+ contextTest array...
313
+
314
+ test "#904: Destructuring function arguments with same-named variables in scope", ->
315
+ a = b = nonce = {}
316
+ fn = ([a,b]) -> {a:a,b:b}
317
+ result = fn([c={},d={}])
318
+ eq c, result.a
319
+ eq d, result.b
320
+ eq nonce, a
321
+ eq nonce, b
322
+
323
+ test "Simple Destructuring function arguments with same-named variables in scope", ->
324
+ x = 1
325
+ f = ([x]) -> x
326
+ eq f([2]), 2
327
+ eq x, 1
328
+
329
+ test "caching base value", ->
330
+
331
+ obj =
332
+ index: 0
333
+ 0: {method: -> this is obj[0]}
334
+ ok obj[obj.index++].method([]...)
335
+
336
+
337
+ test "passing splats to functions", ->
338
+ arrayEq [0..4], id id [0..4]...
339
+ fn = (a, b, c..., d) -> [a, b, c, d]
340
+ range = [0..3]
341
+ [first, second, others, last] = fn range..., 4, [5...8]...
342
+ eq 0, first
343
+ eq 1, second
344
+ arrayEq [2..6], others
345
+ eq 7, last
346
+
347
+ test "splat variables are local to the function", ->
348
+ outer = "x"
349
+ clobber = (avar, outer...) -> outer
350
+ clobber "foo", "bar"
351
+ eq "x", outer
352
+
353
+
354
+ test "Issue 894: Splatting against constructor-chained functions.", ->
355
+
356
+ x = null
357
+ class Foo
358
+ bar: (y) -> x = y
359
+ new Foo().bar([101]...)
360
+ eq x, 101
361
+
362
+
363
+ test "Functions with splats being called with too few arguments.", ->
364
+
365
+ pen = null
366
+ method = (first, variable..., penultimate, ultimate) ->
367
+ pen = penultimate
368
+ method 1, 2, 3, 4, 5, 6, 7, 8, 9
369
+ ok pen is 8
370
+ method 1, 2, 3
371
+ ok pen is 2
372
+ method 1, 2
373
+ ok pen is 2
374
+
375
+
376
+ test "splats with super() within classes.", ->
377
+
378
+ class Parent
379
+ meth: (args...) ->
380
+ args
381
+ class Child extends Parent
382
+ meth: ->
383
+ nums = [3, 2, 1]
384
+ super nums...
385
+ ok (new Child).meth().join(' ') is '3 2 1'
386
+
387
+
388
+ test "#1011: passing a splat to a method of a number", ->
389
+ eq '1011', 11.toString [2]...
390
+ eq '1011', (31).toString [3]...
391
+ eq '1011', 69.0.toString [4]...
392
+ eq '1011', (131.0).toString [5]...
393
+
394
+
395
+ test "splats and the `new` operator: functions that return `null` should construct their instance", ->
396
+ args = []
397
+ child = new (constructor = -> null) args...
398
+ ok child instanceof constructor
399
+
400
+ test "splats and the `new` operator: functions that return functions should construct their return value", ->
401
+ args = []
402
+ fn = ->
403
+ child = new (constructor = -> fn) args...
404
+ ok child not instanceof constructor
405
+ eq fn, child
406
+
407
+ test "implicit return", ->
408
+
409
+ eq ok, new ->
410
+ ok
411
+ ### Should `return` implicitly ###
412
+ ### even with trailing comments. ###
413
+
414
+
415
+ test "implicit returns with multiple branches", ->
416
+ nonce = {}
417
+ fn = ->
418
+ if false
419
+ for a in b
420
+ return c if d
421
+ else
422
+ nonce
423
+ eq nonce, fn()
424
+
425
+
426
+ test "implicit returns with switches", ->
427
+ nonce = {}
428
+ fn = ->
429
+ switch nonce
430
+ when nonce then nonce
431
+ else return undefined
432
+ eq nonce, fn()
433
+
434
+
435
+ test "preserve context when generating closure wrappers for expression conversions", ->
436
+ nonce = {}
437
+ obj =
438
+ property: nonce
439
+ method: ->
440
+ this.result = if false
441
+ 10
442
+ else
443
+ "a"
444
+ "b"
445
+ this.property
446
+ eq nonce, obj.method()
447
+ eq nonce, obj.property
448
+
449
+
450
+ test "don't wrap 'pure' statements in a closure", ->
451
+ nonce = {}
452
+ items = [0, 1, 2, 3, nonce, 4, 5]
453
+ fn = (items) ->
454
+ for item in items
455
+ return item if item is nonce
456
+ eq nonce, fn items
457
+
458
+
459
+ test "usage of `new` is careful about where the invocation parens end up", ->
460
+ eq 'object', typeof new try Array
461
+ eq 'object', typeof new do -> ->
462
+
463
+
464
+ test "implicit call against control structures", ->
465
+ result = null
466
+ save = (obj) -> result = obj
467
+
468
+ save switch id false
469
+ when true
470
+ 'true'
471
+ when false
472
+ 'false'
473
+
474
+ eq result, 'false'
475
+
476
+ save if id false
477
+ 'false'
478
+ else
479
+ 'true'
480
+
481
+ eq result, 'true'
482
+
483
+ save unless id false
484
+ 'true'
485
+ else
486
+ 'false'
487
+
488
+ eq result, 'true'
489
+
490
+ save try
491
+ doesnt exist
492
+ catch error
493
+ 'caught'
494
+
495
+ eq result, 'caught'
496
+
497
+ save try doesnt(exist) catch error then 'caught2'
498
+
499
+ eq result, 'caught2'
500
+
501
+
502
+ test "#1420: things like `(fn() ->)`; there are no words for this one", ->
503
+ fn = -> (f) -> f()
504
+ nonce = {}
505
+ eq nonce, (fn() -> nonce)
506
+
507
+ test "#1416: don't omit one 'new' when compiling 'new new'", ->
508
+ nonce = {}
509
+ obj = new new -> -> {prop: nonce}
510
+ eq obj.prop, nonce
511
+
512
+ test "#1416: don't omit one 'new' when compiling 'new new fn()()'", ->
513
+ nonce = {}
514
+ argNonceA = {}
515
+ argNonceB = {}
516
+ fn = (a) -> (b) -> {a, b, prop: nonce}
517
+ obj = new new fn(argNonceA)(argNonceB)
518
+ eq obj.prop, nonce
519
+ eq obj.a, argNonceA
520
+ eq obj.b, argNonceB
521
+
522
+ test "#1840: accessing the `prototype` after function invocation should compile", ->
523
+ doesNotThrow -> CoffeeScript.compile 'fn()::prop'
524
+
525
+ nonce = {}
526
+ class Test then id: nonce
527
+
528
+ dotAccess = -> Test::
529
+ protoAccess = -> Test
530
+
531
+ eq dotAccess().id, nonce
532
+ eq protoAccess()::id, nonce
533
+
534
+ test "#960: improved 'do'", ->
535
+
536
+ do (nonExistent = 'one') ->
537
+ eq nonExistent, 'one'
538
+
539
+ overridden = 1
540
+ do (overridden = 2) ->
541
+ eq overridden, 2
542
+
543
+ two = 2
544
+ do (one = 1, two, three = 3) ->
545
+ eq one, 1
546
+ eq two, 2
547
+ eq three, 3
548
+
549
+ ret = do func = (two) ->
550
+ eq two, 2
551
+ func
552
+ eq ret, func