guard-mthaml 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +34 -0
- data/lib/guard/mthaml.rb +140 -0
- data/lib/guard/mthaml/compiler/MtHaml.php +255 -0
- data/lib/guard/mthaml/templates/Guardfile +12 -0
- data/lib/guard/mthaml/version.rb +5 -0
- data/vendor/autoload.php +7 -0
- data/vendor/coffeescript/coffeescript/LICENSE +22 -0
- data/vendor/coffeescript/coffeescript/README.md +96 -0
- data/vendor/coffeescript/coffeescript/composer.json +23 -0
- data/vendor/coffeescript/coffeescript/grammar.y +309 -0
- data/vendor/coffeescript/coffeescript/make.php +115 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Compiler.php +76 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Error.php +15 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Helpers.php +116 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Init.php +96 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Lexer.php +1356 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Nodes.php +105 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Parser.php +3326 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Rewriter.php +552 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Scope.php +196 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/SyntaxError.php +9 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/Value.php +20 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Access.php +31 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Arr.php +69 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Assign.php +353 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Base.php +288 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Block.php +294 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Call.php +283 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Class.php +282 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Closure.php +49 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Code.php +203 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Comment.php +39 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Existence.php +42 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Extends.php +26 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/For.php +250 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/If.php +161 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/In.php +99 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Index.php +27 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Literal.php +96 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Obj.php +126 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Op.php +292 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Param.php +119 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Parens.php +45 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Range.php +225 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Return.php +56 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Slice.php +47 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Splat.php +100 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Switch.php +121 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Throw.php +37 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Try.php +79 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/Value.php +210 -0
- data/vendor/coffeescript/coffeescript/src/CoffeeScript/yy/While.php +112 -0
- data/vendor/coffeescript/coffeescript/tests/cases/arrays.coffee +77 -0
- data/vendor/coffeescript/coffeescript/tests/cases/assignment.coffee +352 -0
- data/vendor/coffeescript/coffeescript/tests/cases/booleans.coffee +21 -0
- data/vendor/coffeescript/coffeescript/tests/cases/classes.coffee +681 -0
- data/vendor/coffeescript/coffeescript/tests/cases/comments.coffee +207 -0
- data/vendor/coffeescript/coffeescript/tests/cases/compilation.coffee +72 -0
- data/vendor/coffeescript/coffeescript/tests/cases/comprehensions.coffee +501 -0
- data/vendor/coffeescript/coffeescript/tests/cases/control_flow.coffee +430 -0
- data/vendor/coffeescript/coffeescript/tests/cases/eval.coffee +29 -0
- data/vendor/coffeescript/coffeescript/tests/cases/exception_handling.coffee +102 -0
- data/vendor/coffeescript/coffeescript/tests/cases/formatting.coffee +146 -0
- data/vendor/coffeescript/coffeescript/tests/cases/function_invocation.coffee +552 -0
- data/vendor/coffeescript/coffeescript/tests/cases/functions.coffee +188 -0
- data/vendor/coffeescript/coffeescript/tests/cases/helpers.coffee +96 -0
- data/vendor/coffeescript/coffeescript/tests/cases/importing.coffee +18 -0
- data/vendor/coffeescript/coffeescript/tests/cases/interpolation.coffee +138 -0
- data/vendor/coffeescript/coffeescript/tests/cases/javascript_literals.coffee +10 -0
- data/vendor/coffeescript/coffeescript/tests/cases/numbers.coffee +76 -0
- data/vendor/coffeescript/coffeescript/tests/cases/objects.coffee +271 -0
- data/vendor/coffeescript/coffeescript/tests/cases/operators.coffee +277 -0
- data/vendor/coffeescript/coffeescript/tests/cases/option_parser.coffee +43 -0
- data/vendor/coffeescript/coffeescript/tests/cases/ranges.coffee +88 -0
- data/vendor/coffeescript/coffeescript/tests/cases/regexps.coffee +63 -0
- data/vendor/coffeescript/coffeescript/tests/cases/scope.coffee +43 -0
- data/vendor/coffeescript/coffeescript/tests/cases/slicing_and_splicing.coffee +143 -0
- data/vendor/coffeescript/coffeescript/tests/cases/soaks.coffee +134 -0
- data/vendor/coffeescript/coffeescript/tests/cases/strict.coffee +155 -0
- data/vendor/coffeescript/coffeescript/tests/cases/strings.coffee +107 -0
- data/vendor/coffeescript/coffeescript/tests/css/style.css +43 -0
- data/vendor/coffeescript/coffeescript/tests/index.php +119 -0
- data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.1.1.js +8 -0
- data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.2.0.js +8 -0
- data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.3.0.js +8 -0
- data/vendor/coffeescript/coffeescript/tests/js/lib/coffeescript_1.3.1.js +8 -0
- data/vendor/coffeescript/coffeescript/tests/js/lib/diff.js +276 -0
- data/vendor/coffeescript/coffeescript/tests/js/main.js +123 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/LICENSE.txt +10 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/Lempar.php +948 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Action.php +257 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/ActionTable.php +299 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Config.php +574 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Data.php +1857 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Parser.php +851 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/PropagationLink.php +126 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Rule.php +144 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/State.php +283 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/Symbol.php +288 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/PHP/ParserGenerator/cli.php +5 -0
- data/vendor/coffeescript/coffeescript/vendor/ParserGenerator/ParserGenerator.php +811 -0
- data/vendor/composer/ClassLoader.php +383 -0
- data/vendor/composer/autoload_classmap.php +9 -0
- data/vendor/composer/autoload_namespaces.php +12 -0
- data/vendor/composer/autoload_psr4.php +10 -0
- data/vendor/composer/autoload_real.php +50 -0
- data/vendor/composer/installed.json +166 -0
- data/vendor/michelf/php-markdown/License.md +36 -0
- data/vendor/michelf/php-markdown/Michelf/Markdown.inc.php +10 -0
- data/vendor/michelf/php-markdown/Michelf/Markdown.php +3117 -0
- data/vendor/michelf/php-markdown/Michelf/MarkdownExtra.inc.php +11 -0
- data/vendor/michelf/php-markdown/Michelf/MarkdownExtra.php +38 -0
- data/vendor/michelf/php-markdown/Michelf/MarkdownInterface.inc.php +9 -0
- data/vendor/michelf/php-markdown/Michelf/MarkdownInterface.php +37 -0
- data/vendor/michelf/php-markdown/Readme.md +305 -0
- data/vendor/michelf/php-markdown/Readme.php +31 -0
- data/vendor/michelf/php-markdown/composer.json +31 -0
- data/vendor/mthaml/mthaml/CHANGELOG +48 -0
- data/vendor/mthaml/mthaml/LICENSE +44 -0
- data/vendor/mthaml/mthaml/README.markdown +262 -0
- data/vendor/mthaml/mthaml/composer.json +45 -0
- data/vendor/mthaml/mthaml/docs/Makefile +153 -0
- data/vendor/mthaml/mthaml/docs/_static/mthaml.css +30 -0
- data/vendor/mthaml/mthaml/docs/_theme/mthaml/theme.conf +4 -0
- data/vendor/mthaml/mthaml/docs/conf.py +242 -0
- data/vendor/mthaml/mthaml/docs/index.rst +18 -0
- data/vendor/mthaml/mthaml/docs/twig-syntax.rst +274 -0
- data/vendor/mthaml/mthaml/examples/README.md +5 -0
- data/vendor/mthaml/mthaml/examples/autoload.php +8 -0
- data/vendor/mthaml/mthaml/examples/example-php.haml +5 -0
- data/vendor/mthaml/mthaml/examples/example-php.php +37 -0
- data/vendor/mthaml/mthaml/examples/example-twig-noext.twig +11 -0
- data/vendor/mthaml/mthaml/examples/example-twig.haml +9 -0
- data/vendor/mthaml/mthaml/examples/example-twig.php +60 -0
- data/vendor/mthaml/mthaml/examples/example.twig.haml +8 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Autoloader.php +22 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Environment.php +178 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Escaping.php +33 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Exception.php +9 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Exception/SyntaxErrorException.php +9 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/AbstractFilter.php +43 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Cdata.php +16 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/CoffeeScript.php +33 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Css.php +26 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Escaped.php +22 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/FilterInterface.php +15 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Javascript.php +26 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Less.php +27 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Less/LeafoLess.php +20 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Less/OyejorgeLess.php +23 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown.php +58 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/CebeMarkdown.php +22 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/Ciconia.php +21 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/MichelfMarkdown.php +21 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Markdown/Parsedown.php +21 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Php.php +37 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Plain.php +24 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Preserve.php +19 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Scss.php +37 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Filter/Twig.php +47 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/Indentation.php +96 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/IndentationException.php +9 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/IndentationInterface.php +50 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Indentation/Undefined.php +41 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Comment.php +71 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Doctype.php +96 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/EscapableAbstract.php +19 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Filter.php +51 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Insert.php +42 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/InterpolatedString.php +73 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/NestAbstract.php +117 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/NestInterface.php +10 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/NodeAbstract.php +77 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/ObjectRefClass.php +42 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/ObjectRefId.php +42 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Root.php +35 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Run.php +71 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Statement.php +45 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Tag.php +90 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/TagAttribute.php +62 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/TagAttributeInterpolation.php +24 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/TagAttributeList.php +24 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Node/Text.php +37 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Autoclose.php +25 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Escaping.php +105 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/MergeAttrs.php +110 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Midblock.php +37 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/NodeVisitorAbstract.php +226 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/NodeVisitorInterface.php +97 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/PhpRenderer.php +288 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/Printer.php +265 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/RendererAbstract.php +581 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/NodeVisitor/TwigRenderer.php +252 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Parser.php +862 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Parser/Buffer.php +147 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Runtime.php +218 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Runtime/AttributeInterpolation.php +16 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Runtime/AttributeList.php +16 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Support/Php/Executor.php +157 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Support/Twig/Extension.php +47 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Support/Twig/Lexer.php +48 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Support/Twig/Loader.php +81 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Target/Php.php +23 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Target/TargetAbstract.php +87 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Target/TargetInterface.php +12 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/Target/Twig.php +23 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/TreeBuilder.php +100 -0
- data/vendor/mthaml/mthaml/lib/MtHaml/TreeBuilderException.php +9 -0
- data/vendor/mthaml/mthaml/phpunit.xml +25 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/EnvironmentTest.php +59 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/HamlSpecTest.php +83 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/IndentationTest.php +140 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/Node/DoctypeTest.php +51 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/Node/NodeTest.php +110 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/NodeVisitor/PhpRendererTest.php +113 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/NodeVisitor/TwigRendererTest.php +68 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/NodeVisitorsTest.php +44 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/Parser/BufferTest.php +77 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/ParserTest.php +47 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/RuntimeTest.php +356 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/Support/Php/ExecutorTest.php +83 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/Support/Twig/LoaderTest.php +65 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/TestCase.php +49 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/TestCaseTest.php +50 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/Support/Php/Executor.001.haml +1 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/attr_list_php.test +20 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/attr_list_twig.test +12 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/boolean_attr_php.test +16 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/boolean_attr_twig.test +16 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug28_php.test +15 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug28_twig.test +15 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug42.test +13 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/bug8_twig.test +10 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/coffeescript_filter.test +31 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/comments.test +26 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/cond_cmt.test +25 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype.test +18 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_html4.test +20 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_invalid.test +12 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_invalid_xhtml.test +12 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_php.test +18 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/doctype_xhtml.test +30 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/filters.test +51 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/insert_non_echo_php.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/insert_non_echo_twig.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/interpolation_in_html_attrs_php.test +31 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/interpolation_in_html_attrs_twig.test +31 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/less_filter_leafo.test +33 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/less_filter_oyejorge.test +49 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_cebemarkdown.test +35 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_ciconia.test +36 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_michelf.test +34 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_filter_parsedown.test +31 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/markdown_optimization_filter_michelf.test +23 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/mergeattrs.test +18 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/nuke_inner_whitespace.test +77 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/nuke_outer_whitespace.test +122 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/object_ref_php.test +14 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/object_ref_twig.test +14 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php.test +109 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_autoescaping.test +22 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_autoescaping_once.test +25 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_blocks.test +29 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/php_filters.test +42 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/scss_filter.test +32 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/strip_inline_comments_php.test +22 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/test.test +24 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/trailing_semicolon_php.test +14 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/try_catch_php.test +17 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig.test +112 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig_blocks.test +29 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig_filters.test +37 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/twig_whitespace.test +32 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/environment/whitespace.test +63 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/autoclose.test +30 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/escaping.test +52 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/escaping_attr_once.test +52 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/escaping_html_false.test +52 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/mergeattrs.test +26 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/midblock.test +54 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/nodevisitors/midblock_002.test +32 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attr_list.test +14 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs.test +42 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs_002.test +35 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs_003.test +30 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/attrs_html_linebreak.test +17 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/blocks.test +27 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/blocks_002.test +15 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/boolean_attr.test +19 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/bug28.test +15 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/bug8.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/cond_cmt.test +23 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/doctype.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/double_equal.test +7 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/empty_line_after_multiline.test +10 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_001.test +8 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_002.test +8 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_003.test +8 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_004.test +6 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_005.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_006.test +7 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_007.test +7 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_008.test +7 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_009.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_010.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_013.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_016.test +7 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_017.test +8 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_018.test +6 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_019.test +6 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/errors_020.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters.test +20 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_002.test +19 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_003.test +13 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_004.test +21 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_005.test +22 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/filters_006.test +23 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/insertflags.test +17 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/interpolation.test +36 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/interpolation_in_html_attrs.test +17 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/multiline.test +18 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/multiline_code.test +59 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/multiple_attr_kinds.test +47 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/non_rendered_comment.test +31 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ns.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/object_ref.test +22 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/object_ref_error1.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/object_ref_error2.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/quotes_in_haml.test +10 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby19_attrs.test +11 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma.test +23 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma_errors_001.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma_errors_002.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/ruby_attrs_comma_errors_003.test +5 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/standard.test +114 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/parser/tagflags.test +39 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/runtime/php_filters.test +28 -0
- data/vendor/mthaml/mthaml/test/MtHaml/Tests/fixtures/runtime/twig_filters.test +31 -0
- data/vendor/mthaml/mthaml/test/bootstrap.php +3 -0
- metadata +398 -0
@@ -0,0 +1,430 @@
|
|
1
|
+
# Control Flow
|
2
|
+
# ------------
|
3
|
+
|
4
|
+
# * Conditionals
|
5
|
+
# * Loops
|
6
|
+
# * For
|
7
|
+
# * While
|
8
|
+
# * Until
|
9
|
+
# * Loop
|
10
|
+
# * Switch
|
11
|
+
# * Throw
|
12
|
+
|
13
|
+
# TODO: make sure postfix forms and expression coercion are properly tested
|
14
|
+
|
15
|
+
# shared identity function
|
16
|
+
id = (_) -> if arguments.length is 1 then _ else Array::slice.call(arguments)
|
17
|
+
|
18
|
+
# Conditionals
|
19
|
+
|
20
|
+
test "basic conditionals", ->
|
21
|
+
if false
|
22
|
+
ok false
|
23
|
+
else if false
|
24
|
+
ok false
|
25
|
+
else
|
26
|
+
ok true
|
27
|
+
|
28
|
+
if true
|
29
|
+
ok true
|
30
|
+
else if true
|
31
|
+
ok false
|
32
|
+
else
|
33
|
+
ok true
|
34
|
+
|
35
|
+
unless true
|
36
|
+
ok false
|
37
|
+
else unless true
|
38
|
+
ok false
|
39
|
+
else
|
40
|
+
ok true
|
41
|
+
|
42
|
+
unless false
|
43
|
+
ok true
|
44
|
+
else unless false
|
45
|
+
ok false
|
46
|
+
else
|
47
|
+
ok true
|
48
|
+
|
49
|
+
test "single-line conditional", ->
|
50
|
+
if false then ok false else ok true
|
51
|
+
unless false then ok true else ok false
|
52
|
+
|
53
|
+
test "nested conditionals", ->
|
54
|
+
nonce = {}
|
55
|
+
eq nonce, (if true
|
56
|
+
unless false
|
57
|
+
if false then false else
|
58
|
+
if true
|
59
|
+
nonce)
|
60
|
+
|
61
|
+
test "nested single-line conditionals", ->
|
62
|
+
nonce = {}
|
63
|
+
|
64
|
+
a = if false then undefined else b = if 0 then undefined else nonce
|
65
|
+
eq nonce, a
|
66
|
+
eq nonce, b
|
67
|
+
|
68
|
+
c = if false then undefined else (if 0 then undefined else nonce)
|
69
|
+
eq nonce, c
|
70
|
+
|
71
|
+
d = if true then id(if false then undefined else nonce)
|
72
|
+
eq nonce, d
|
73
|
+
|
74
|
+
test "empty conditional bodies", ->
|
75
|
+
eq undefined, (if false
|
76
|
+
else if false
|
77
|
+
else)
|
78
|
+
|
79
|
+
test "conditional bodies containing only comments", ->
|
80
|
+
eq undefined, (if true
|
81
|
+
###
|
82
|
+
block comment
|
83
|
+
###
|
84
|
+
else
|
85
|
+
# comment
|
86
|
+
)
|
87
|
+
|
88
|
+
eq undefined, (if false
|
89
|
+
# comment
|
90
|
+
else if true
|
91
|
+
###
|
92
|
+
block comment
|
93
|
+
###
|
94
|
+
else)
|
95
|
+
|
96
|
+
test "return value of if-else is from the proper body", ->
|
97
|
+
nonce = {}
|
98
|
+
eq nonce, if false then undefined else nonce
|
99
|
+
|
100
|
+
test "return value of unless-else is from the proper body", ->
|
101
|
+
nonce = {}
|
102
|
+
eq nonce, unless true then undefined else nonce
|
103
|
+
|
104
|
+
test "assign inside the condition of a conditional statement", ->
|
105
|
+
nonce = {}
|
106
|
+
if a = nonce then 1
|
107
|
+
eq nonce, a
|
108
|
+
1 if b = nonce
|
109
|
+
eq nonce, b
|
110
|
+
|
111
|
+
|
112
|
+
# Interactions With Functions
|
113
|
+
|
114
|
+
test "single-line function definition with single-line conditional", ->
|
115
|
+
fn = -> if 1 < 0.5 then 1 else -1
|
116
|
+
ok fn() is -1
|
117
|
+
|
118
|
+
test "function resturns conditional value with no `else`", ->
|
119
|
+
fn = ->
|
120
|
+
return if false then true
|
121
|
+
eq undefined, fn()
|
122
|
+
|
123
|
+
test "function returns a conditional value", ->
|
124
|
+
a = {}
|
125
|
+
fnA = ->
|
126
|
+
return if false then undefined else a
|
127
|
+
eq a, fnA()
|
128
|
+
|
129
|
+
b = {}
|
130
|
+
fnB = ->
|
131
|
+
return unless false then b else undefined
|
132
|
+
eq b, fnB()
|
133
|
+
|
134
|
+
test "passing a conditional value to a function", ->
|
135
|
+
nonce = {}
|
136
|
+
eq nonce, id if false then undefined else nonce
|
137
|
+
|
138
|
+
test "unmatched `then` should catch implicit calls", ->
|
139
|
+
a = 0
|
140
|
+
trueFn = -> true
|
141
|
+
if trueFn undefined then a++
|
142
|
+
eq 1, a
|
143
|
+
|
144
|
+
|
145
|
+
# if-to-ternary
|
146
|
+
|
147
|
+
test "if-to-ternary with instanceof requires parentheses", ->
|
148
|
+
nonce = {}
|
149
|
+
eq nonce, (if {} instanceof Object
|
150
|
+
nonce
|
151
|
+
else
|
152
|
+
undefined)
|
153
|
+
|
154
|
+
test "if-to-ternary as part of a larger operation requires parentheses", ->
|
155
|
+
ok 2, 1 + if false then 0 else 1
|
156
|
+
|
157
|
+
|
158
|
+
# Odd Formatting
|
159
|
+
|
160
|
+
test "if-else indented within an assignment", ->
|
161
|
+
nonce = {}
|
162
|
+
result =
|
163
|
+
if false
|
164
|
+
undefined
|
165
|
+
else
|
166
|
+
nonce
|
167
|
+
eq nonce, result
|
168
|
+
|
169
|
+
test "suppressed indentation via assignment", ->
|
170
|
+
nonce = {}
|
171
|
+
result =
|
172
|
+
if false then undefined
|
173
|
+
else if no then undefined
|
174
|
+
else if 0 then undefined
|
175
|
+
else if 1 < 0 then undefined
|
176
|
+
else id(
|
177
|
+
if false then undefined
|
178
|
+
else nonce
|
179
|
+
)
|
180
|
+
eq nonce, result
|
181
|
+
|
182
|
+
test "tight formatting with leading `then`", ->
|
183
|
+
nonce = {}
|
184
|
+
eq nonce,
|
185
|
+
if true
|
186
|
+
then nonce
|
187
|
+
else undefined
|
188
|
+
|
189
|
+
test "#738", ->
|
190
|
+
nonce = {}
|
191
|
+
fn = if true then -> nonce
|
192
|
+
eq nonce, fn()
|
193
|
+
|
194
|
+
test "#748: trailing reserved identifiers", ->
|
195
|
+
nonce = {}
|
196
|
+
obj = delete: true
|
197
|
+
result = if obj.delete
|
198
|
+
nonce
|
199
|
+
eq nonce, result
|
200
|
+
|
201
|
+
|
202
|
+
test "basic `while` loops", ->
|
203
|
+
|
204
|
+
i = 5
|
205
|
+
list = while i -= 1
|
206
|
+
i * 2
|
207
|
+
ok list.join(' ') is "8 6 4 2"
|
208
|
+
|
209
|
+
i = 5
|
210
|
+
list = (i * 3 while i -= 1)
|
211
|
+
ok list.join(' ') is "12 9 6 3"
|
212
|
+
|
213
|
+
i = 5
|
214
|
+
func = (num) -> i -= num
|
215
|
+
assert = -> ok i < 5 > 0
|
216
|
+
results = while func 1
|
217
|
+
assert()
|
218
|
+
i
|
219
|
+
ok results.join(' ') is '4 3 2 1'
|
220
|
+
|
221
|
+
i = 10
|
222
|
+
results = while i -= 1 when i % 2 is 0
|
223
|
+
i * 2
|
224
|
+
ok results.join(' ') is '16 12 8 4'
|
225
|
+
|
226
|
+
|
227
|
+
test "Issue 759: `if` within `while` condition", ->
|
228
|
+
|
229
|
+
2 while if 1 then 0
|
230
|
+
|
231
|
+
|
232
|
+
test "assignment inside the condition of a `while` loop", ->
|
233
|
+
|
234
|
+
nonce = {}
|
235
|
+
count = 1
|
236
|
+
a = nonce while count--
|
237
|
+
eq nonce, a
|
238
|
+
count = 1
|
239
|
+
while count--
|
240
|
+
b = nonce
|
241
|
+
eq nonce, b
|
242
|
+
|
243
|
+
|
244
|
+
test "While over break.", ->
|
245
|
+
|
246
|
+
i = 0
|
247
|
+
result = while i < 10
|
248
|
+
i++
|
249
|
+
break
|
250
|
+
arrayEq result, []
|
251
|
+
|
252
|
+
|
253
|
+
test "While over continue.", ->
|
254
|
+
|
255
|
+
i = 0
|
256
|
+
result = while i < 10
|
257
|
+
i++
|
258
|
+
continue
|
259
|
+
arrayEq result, []
|
260
|
+
|
261
|
+
|
262
|
+
test "Basic `until`", ->
|
263
|
+
|
264
|
+
value = false
|
265
|
+
i = 0
|
266
|
+
results = until value
|
267
|
+
value = true if i is 5
|
268
|
+
i++
|
269
|
+
ok i is 6
|
270
|
+
|
271
|
+
|
272
|
+
test "Basic `loop`", ->
|
273
|
+
|
274
|
+
i = 5
|
275
|
+
list = []
|
276
|
+
loop
|
277
|
+
i -= 1
|
278
|
+
break if i is 0
|
279
|
+
list.push i * 2
|
280
|
+
ok list.join(' ') is '8 6 4 2'
|
281
|
+
|
282
|
+
|
283
|
+
test "break at the top level", ->
|
284
|
+
for i in [1,2,3]
|
285
|
+
result = i
|
286
|
+
if i == 2
|
287
|
+
break
|
288
|
+
eq 2, result
|
289
|
+
|
290
|
+
test "break *not* at the top level", ->
|
291
|
+
someFunc = ->
|
292
|
+
i = 0
|
293
|
+
while ++i < 3
|
294
|
+
result = i
|
295
|
+
break if i > 1
|
296
|
+
result
|
297
|
+
eq 2, someFunc()
|
298
|
+
|
299
|
+
|
300
|
+
test "basic `switch`", ->
|
301
|
+
|
302
|
+
num = 10
|
303
|
+
result = switch num
|
304
|
+
when 5 then false
|
305
|
+
when 'a'
|
306
|
+
true
|
307
|
+
true
|
308
|
+
false
|
309
|
+
when 10 then true
|
310
|
+
|
311
|
+
|
312
|
+
# Mid-switch comment with whitespace
|
313
|
+
# and multi line
|
314
|
+
when 11 then false
|
315
|
+
else false
|
316
|
+
|
317
|
+
ok result
|
318
|
+
|
319
|
+
|
320
|
+
func = (num) ->
|
321
|
+
switch num
|
322
|
+
when 2, 4, 6
|
323
|
+
true
|
324
|
+
when 1, 3, 5
|
325
|
+
false
|
326
|
+
|
327
|
+
ok func(2)
|
328
|
+
ok func(6)
|
329
|
+
ok !func(3)
|
330
|
+
eq func(8), undefined
|
331
|
+
|
332
|
+
|
333
|
+
test "Ensure that trailing switch elses don't get rewritten.", ->
|
334
|
+
|
335
|
+
result = false
|
336
|
+
switch "word"
|
337
|
+
when "one thing"
|
338
|
+
doSomething()
|
339
|
+
else
|
340
|
+
result = true unless false
|
341
|
+
|
342
|
+
ok result
|
343
|
+
|
344
|
+
result = false
|
345
|
+
switch "word"
|
346
|
+
when "one thing"
|
347
|
+
doSomething()
|
348
|
+
when "other thing"
|
349
|
+
doSomething()
|
350
|
+
else
|
351
|
+
result = true unless false
|
352
|
+
|
353
|
+
ok result
|
354
|
+
|
355
|
+
|
356
|
+
test "Should be able to handle switches sans-condition.", ->
|
357
|
+
|
358
|
+
result = switch
|
359
|
+
when null then 0
|
360
|
+
when !1 then 1
|
361
|
+
when '' not of {''} then 2
|
362
|
+
when [] not instanceof Array then 3
|
363
|
+
when true is false then 4
|
364
|
+
when 'x' < 'y' > 'z' then 5
|
365
|
+
when 'a' in ['b', 'c'] then 6
|
366
|
+
when 'd' in (['e', 'f']) then 7
|
367
|
+
else ok
|
368
|
+
|
369
|
+
eq result, ok
|
370
|
+
|
371
|
+
|
372
|
+
test "Should be able to use `@properties` within the switch clause.", ->
|
373
|
+
|
374
|
+
obj = {
|
375
|
+
num: 101
|
376
|
+
func: ->
|
377
|
+
switch @num
|
378
|
+
when 101 then '101!'
|
379
|
+
else 'other'
|
380
|
+
}
|
381
|
+
|
382
|
+
ok obj.func() is '101!'
|
383
|
+
|
384
|
+
|
385
|
+
test "Should be able to use `@properties` within the switch cases.", ->
|
386
|
+
|
387
|
+
obj = {
|
388
|
+
num: 101
|
389
|
+
func: (yesOrNo) ->
|
390
|
+
result = switch yesOrNo
|
391
|
+
when yes then @num
|
392
|
+
else 'other'
|
393
|
+
result
|
394
|
+
}
|
395
|
+
|
396
|
+
ok obj.func(yes) is 101
|
397
|
+
|
398
|
+
|
399
|
+
test "Switch with break as the return value of a loop.", ->
|
400
|
+
|
401
|
+
i = 10
|
402
|
+
results = while i > 0
|
403
|
+
i--
|
404
|
+
switch i % 2
|
405
|
+
when 1 then i
|
406
|
+
when 0 then break
|
407
|
+
|
408
|
+
eq results.join(', '), '9, 7, 5, 3, 1'
|
409
|
+
|
410
|
+
|
411
|
+
test "Issue #997. Switch doesn't fallthrough.", ->
|
412
|
+
|
413
|
+
val = 1
|
414
|
+
switch true
|
415
|
+
when true
|
416
|
+
if false
|
417
|
+
return 5
|
418
|
+
else
|
419
|
+
val = 2
|
420
|
+
|
421
|
+
eq val, 1
|
422
|
+
|
423
|
+
|
424
|
+
test "Throw should be usable as an expression.", ->
|
425
|
+
|
426
|
+
try
|
427
|
+
false or throw 'up'
|
428
|
+
throw new Error 'failed'
|
429
|
+
catch e
|
430
|
+
ok e is 'up'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
if vm = require? 'vm'
|
2
|
+
|
3
|
+
test "CoffeeScript.eval runs in the global context by default", ->
|
4
|
+
global.punctuation = '!'
|
5
|
+
code = '''
|
6
|
+
global.fhqwhgads = "global superpower#{global.punctuation}"
|
7
|
+
'''
|
8
|
+
result = CoffeeScript.eval code
|
9
|
+
eq result, 'global superpower!'
|
10
|
+
eq fhqwhgads, 'global superpower!'
|
11
|
+
|
12
|
+
test "CoffeeScript.eval can run in, and modify, a Script context sandbox", ->
|
13
|
+
sandbox = vm.Script.createContext()
|
14
|
+
sandbox.foo = 'bar'
|
15
|
+
code = '''
|
16
|
+
global.foo = 'not bar!'
|
17
|
+
'''
|
18
|
+
result = CoffeeScript.eval code, {sandbox}
|
19
|
+
eq result, 'not bar!'
|
20
|
+
eq sandbox.foo, 'not bar!'
|
21
|
+
|
22
|
+
test "CoffeeScript.eval can run in, but cannot modify, an ordinary object sandbox", ->
|
23
|
+
sandbox = {foo: 'bar'}
|
24
|
+
code = '''
|
25
|
+
global.foo = 'not bar!'
|
26
|
+
'''
|
27
|
+
result = CoffeeScript.eval code, {sandbox}
|
28
|
+
eq result, 'not bar!'
|
29
|
+
eq sandbox.foo, 'bar'
|