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,352 @@
|
|
1
|
+
# Assignment
|
2
|
+
# ----------
|
3
|
+
|
4
|
+
# * Assignment
|
5
|
+
# * Compound Assignment
|
6
|
+
# * Destructuring Assignment
|
7
|
+
# * Context Property (@) Assignment
|
8
|
+
# * Existential Assignment (?=)
|
9
|
+
|
10
|
+
test "context property assignment (using @)", ->
|
11
|
+
nonce = {}
|
12
|
+
addMethod = ->
|
13
|
+
@method = -> nonce
|
14
|
+
this
|
15
|
+
eq nonce, addMethod.call({}).method()
|
16
|
+
|
17
|
+
test "unassignable values", ->
|
18
|
+
nonce = {}
|
19
|
+
for nonref in ['', '""', '0', 'f()'].concat CoffeeScript.RESERVED
|
20
|
+
eq nonce, (try CoffeeScript.compile "#{nonref} = v" catch e then nonce)
|
21
|
+
|
22
|
+
# Compound Assignment
|
23
|
+
|
24
|
+
test "boolean operators", ->
|
25
|
+
nonce = {}
|
26
|
+
|
27
|
+
a = 0
|
28
|
+
a or= nonce
|
29
|
+
eq nonce, a
|
30
|
+
|
31
|
+
b = 1
|
32
|
+
b or= nonce
|
33
|
+
eq 1, b
|
34
|
+
|
35
|
+
c = 0
|
36
|
+
c and= nonce
|
37
|
+
eq 0, c
|
38
|
+
|
39
|
+
d = 1
|
40
|
+
d and= nonce
|
41
|
+
eq nonce, d
|
42
|
+
|
43
|
+
# ensure that RHS is treated as a group
|
44
|
+
e = f = false
|
45
|
+
e and= f or true
|
46
|
+
eq false, e
|
47
|
+
|
48
|
+
test "compound assignment as a sub expression", ->
|
49
|
+
[a, b, c] = [1, 2, 3]
|
50
|
+
eq 6, (a + b += c)
|
51
|
+
eq 1, a
|
52
|
+
eq 5, b
|
53
|
+
eq 3, c
|
54
|
+
|
55
|
+
# *note: this test could still use refactoring*
|
56
|
+
test "compound assignment should be careful about caching variables", ->
|
57
|
+
count = 0
|
58
|
+
list = []
|
59
|
+
|
60
|
+
list[++count] or= 1
|
61
|
+
eq 1, list[1]
|
62
|
+
eq 1, count
|
63
|
+
|
64
|
+
list[++count] ?= 2
|
65
|
+
eq 2, list[2]
|
66
|
+
eq 2, count
|
67
|
+
|
68
|
+
list[count++] and= 6
|
69
|
+
eq 6, list[2]
|
70
|
+
eq 3, count
|
71
|
+
|
72
|
+
base = ->
|
73
|
+
++count
|
74
|
+
base
|
75
|
+
|
76
|
+
base().four or= 4
|
77
|
+
eq 4, base.four
|
78
|
+
eq 4, count
|
79
|
+
|
80
|
+
base().five ?= 5
|
81
|
+
eq 5, base.five
|
82
|
+
eq 5, count
|
83
|
+
|
84
|
+
test "compound assignment with implicit objects", ->
|
85
|
+
obj = undefined
|
86
|
+
obj ?=
|
87
|
+
one: 1
|
88
|
+
|
89
|
+
eq 1, obj.one
|
90
|
+
|
91
|
+
obj and=
|
92
|
+
two: 2
|
93
|
+
|
94
|
+
eq undefined, obj.one
|
95
|
+
eq 2, obj.two
|
96
|
+
|
97
|
+
test "compound assignment (math operators)", ->
|
98
|
+
num = 10
|
99
|
+
num -= 5
|
100
|
+
eq 5, num
|
101
|
+
|
102
|
+
num *= 10
|
103
|
+
eq 50, num
|
104
|
+
|
105
|
+
num /= 10
|
106
|
+
eq 5, num
|
107
|
+
|
108
|
+
num %= 3
|
109
|
+
eq 2, num
|
110
|
+
|
111
|
+
test "more compound assignment", ->
|
112
|
+
a = {}
|
113
|
+
val = undefined
|
114
|
+
val ||= a
|
115
|
+
val ||= true
|
116
|
+
eq a, val
|
117
|
+
|
118
|
+
b = {}
|
119
|
+
val &&= true
|
120
|
+
eq val, true
|
121
|
+
val &&= b
|
122
|
+
eq b, val
|
123
|
+
|
124
|
+
c = {}
|
125
|
+
val = null
|
126
|
+
val ?= c
|
127
|
+
val ?= true
|
128
|
+
eq c, val
|
129
|
+
|
130
|
+
|
131
|
+
# Destructuring Assignment
|
132
|
+
|
133
|
+
test "empty destructuring assignment", ->
|
134
|
+
{} = [] = undefined
|
135
|
+
|
136
|
+
test "chained destructuring assignments", ->
|
137
|
+
[a] = {0: b} = {'0': c} = [nonce={}]
|
138
|
+
eq nonce, a
|
139
|
+
eq nonce, b
|
140
|
+
eq nonce, c
|
141
|
+
|
142
|
+
test "variable swapping to verify caching of RHS values when appropriate", ->
|
143
|
+
a = nonceA = {}
|
144
|
+
b = nonceB = {}
|
145
|
+
c = nonceC = {}
|
146
|
+
[a, b, c] = [b, c, a]
|
147
|
+
eq nonceB, a
|
148
|
+
eq nonceC, b
|
149
|
+
eq nonceA, c
|
150
|
+
[a, b, c] = [b, c, a]
|
151
|
+
eq nonceC, a
|
152
|
+
eq nonceA, b
|
153
|
+
eq nonceB, c
|
154
|
+
fn = ->
|
155
|
+
[a, b, c] = [b, c, a]
|
156
|
+
arrayEq [nonceA,nonceB,nonceC], fn()
|
157
|
+
eq nonceA, a
|
158
|
+
eq nonceB, b
|
159
|
+
eq nonceC, c
|
160
|
+
|
161
|
+
test "#713", ->
|
162
|
+
nonces = [nonceA={},nonceB={}]
|
163
|
+
eq nonces, [a, b] = [c, d] = nonces
|
164
|
+
eq nonceA, a
|
165
|
+
eq nonceA, c
|
166
|
+
eq nonceB, b
|
167
|
+
eq nonceB, d
|
168
|
+
|
169
|
+
test "destructuring assignment with splats", ->
|
170
|
+
a = {}; b = {}; c = {}; d = {}; e = {}
|
171
|
+
[x,y...,z] = [a,b,c,d,e]
|
172
|
+
eq a, x
|
173
|
+
arrayEq [b,c,d], y
|
174
|
+
eq e, z
|
175
|
+
|
176
|
+
test "deep destructuring assignment with splats", ->
|
177
|
+
a={}; b={}; c={}; d={}; e={}; f={}; g={}; h={}; i={}
|
178
|
+
[u, [v, w..., x], y..., z] = [a, [b, c, d, e], f, g, h, i]
|
179
|
+
eq a, u
|
180
|
+
eq b, v
|
181
|
+
arrayEq [c,d], w
|
182
|
+
eq e, x
|
183
|
+
arrayEq [f,g,h], y
|
184
|
+
eq i, z
|
185
|
+
|
186
|
+
test "destructuring assignment with objects", ->
|
187
|
+
a={}; b={}; c={}
|
188
|
+
obj = {a,b,c}
|
189
|
+
{a:x, b:y, c:z} = obj
|
190
|
+
eq a, x
|
191
|
+
eq b, y
|
192
|
+
eq c, z
|
193
|
+
|
194
|
+
test "deep destructuring assignment with objects", ->
|
195
|
+
a={}; b={}; c={}; d={}
|
196
|
+
obj = {
|
197
|
+
a
|
198
|
+
b: {
|
199
|
+
'c': {
|
200
|
+
d: [
|
201
|
+
b
|
202
|
+
{e: c, f: d}
|
203
|
+
]
|
204
|
+
}
|
205
|
+
}
|
206
|
+
}
|
207
|
+
{a: w, 'b': {c: d: [x, {'f': z, e: y}]}} = obj
|
208
|
+
eq a, w
|
209
|
+
eq b, x
|
210
|
+
eq c, y
|
211
|
+
eq d, z
|
212
|
+
|
213
|
+
test "destructuring assignment with objects and splats", ->
|
214
|
+
a={}; b={}; c={}; d={}
|
215
|
+
obj = a: b: [a, b, c, d]
|
216
|
+
{a: b: [y, z...]} = obj
|
217
|
+
eq a, y
|
218
|
+
arrayEq [b,c,d], z
|
219
|
+
|
220
|
+
test "destructuring assignment against an expression", ->
|
221
|
+
a={}; b={}
|
222
|
+
[y, z] = if true then [a, b] else [b, a]
|
223
|
+
eq a, y
|
224
|
+
eq b, z
|
225
|
+
|
226
|
+
test "bracket insertion when necessary", ->
|
227
|
+
[a] = [0] ? [1]
|
228
|
+
eq a, 0
|
229
|
+
|
230
|
+
# for implicit destructuring assignment in comprehensions, see the comprehension tests
|
231
|
+
|
232
|
+
test "destructuring assignment with context (@) properties", ->
|
233
|
+
a={}; b={}; c={}; d={}; e={}
|
234
|
+
obj =
|
235
|
+
fn: () ->
|
236
|
+
local = [a, {b, c}, d, e]
|
237
|
+
[@a, {b: @b, c: @c}, @d, @e] = local
|
238
|
+
eq undefined, obj[key] for key in ['a','b','c','d','e']
|
239
|
+
obj.fn()
|
240
|
+
eq a, obj.a
|
241
|
+
eq b, obj.b
|
242
|
+
eq c, obj.c
|
243
|
+
eq d, obj.d
|
244
|
+
eq e, obj.e
|
245
|
+
|
246
|
+
test "#1024", ->
|
247
|
+
eq 2 * [] = 3 + 5, 16
|
248
|
+
|
249
|
+
test "#1005: invalid identifiers allowed on LHS of destructuring assignment", ->
|
250
|
+
disallowed = ['eval', 'arguments'].concat CoffeeScript.RESERVED
|
251
|
+
throws (-> CoffeeScript.compile "[#{disallowed.join ', '}] = x"), null, 'all disallowed'
|
252
|
+
throws (-> CoffeeScript.compile "[#{disallowed.join '..., '}...] = x"), null, 'all disallowed as splats'
|
253
|
+
t = tSplat = null
|
254
|
+
for v in disallowed when v isnt 'class' # `class` by itself is an expression
|
255
|
+
throws (-> CoffeeScript.compile t), null, t = "[#{v}] = x"
|
256
|
+
throws (-> CoffeeScript.compile tSplat), null, tSplat = "[#{v}...] = x"
|
257
|
+
doesNotThrow ->
|
258
|
+
for v in disallowed
|
259
|
+
CoffeeScript.compile "[a.#{v}] = x"
|
260
|
+
CoffeeScript.compile "[a.#{v}...] = x"
|
261
|
+
CoffeeScript.compile "[@#{v}] = x"
|
262
|
+
CoffeeScript.compile "[@#{v}...] = x"
|
263
|
+
|
264
|
+
test "#2055: destructuring assignment with `new`", ->
|
265
|
+
{length} = new Array
|
266
|
+
eq 0, length
|
267
|
+
|
268
|
+
|
269
|
+
# Existential Assignment
|
270
|
+
|
271
|
+
test "existential assignment", ->
|
272
|
+
nonce = {}
|
273
|
+
a = false
|
274
|
+
a ?= nonce
|
275
|
+
eq false, a
|
276
|
+
b = undefined
|
277
|
+
b ?= nonce
|
278
|
+
eq nonce, b
|
279
|
+
c = null
|
280
|
+
c ?= nonce
|
281
|
+
eq nonce, c
|
282
|
+
|
283
|
+
test "#1627: prohibit conditional assignment of undefined variables", ->
|
284
|
+
throws (-> CoffeeScript.compile "x ?= 10"), null, "prohibit (x ?= 10)"
|
285
|
+
throws (-> CoffeeScript.compile "x ||= 10"), null, "prohibit (x ||= 10)"
|
286
|
+
throws (-> CoffeeScript.compile "x or= 10"), null, "prohibit (x or= 10)"
|
287
|
+
throws (-> CoffeeScript.compile "do -> x ?= 10"), null, "prohibit (do -> x ?= 10)"
|
288
|
+
throws (-> CoffeeScript.compile "do -> x ||= 10"), null, "prohibit (do -> x ||= 10)"
|
289
|
+
throws (-> CoffeeScript.compile "do -> x or= 10"), null, "prohibit (do -> x or= 10)"
|
290
|
+
doesNotThrow (-> CoffeeScript.compile "x = null; x ?= 10"), "allow (x = null; x ?= 10)"
|
291
|
+
doesNotThrow (-> CoffeeScript.compile "x = null; x ||= 10"), "allow (x = null; x ||= 10)"
|
292
|
+
doesNotThrow (-> CoffeeScript.compile "x = null; x or= 10"), "allow (x = null; x or= 10)"
|
293
|
+
doesNotThrow (-> CoffeeScript.compile "x = null; do -> x ?= 10"), "allow (x = null; do -> x ?= 10)"
|
294
|
+
doesNotThrow (-> CoffeeScript.compile "x = null; do -> x ||= 10"), "allow (x = null; do -> x ||= 10)"
|
295
|
+
doesNotThrow (-> CoffeeScript.compile "x = null; do -> x or= 10"), "allow (x = null; do -> x or= 10)"
|
296
|
+
|
297
|
+
throws (-> CoffeeScript.compile "-> -> -> x ?= 10"), null, "prohibit (-> -> -> x ?= 10)"
|
298
|
+
doesNotThrow (-> CoffeeScript.compile "x = null; -> -> -> x ?= 10"), "allow (x = null; -> -> -> x ?= 10)"
|
299
|
+
|
300
|
+
test "more existential assignment", ->
|
301
|
+
global.temp ?= 0
|
302
|
+
eq global.temp, 0
|
303
|
+
global.temp or= 100
|
304
|
+
eq global.temp, 100
|
305
|
+
delete global.temp
|
306
|
+
|
307
|
+
test "#1348, #1216: existential assignment compilation", ->
|
308
|
+
nonce = {}
|
309
|
+
a = nonce
|
310
|
+
b = (a ?= 0)
|
311
|
+
eq nonce, b
|
312
|
+
#the first ?= compiles into a statement; the second ?= compiles to a ternary expression
|
313
|
+
eq a ?= b ?= 1, nonce
|
314
|
+
|
315
|
+
if a then a ?= 2 else a = 3
|
316
|
+
eq a, nonce
|
317
|
+
|
318
|
+
test "#1591, #1101: splatted expressions in destructuring assignment must be assignable", ->
|
319
|
+
nonce = {}
|
320
|
+
for nonref in ['', '""', '0', 'f()', '(->)'].concat CoffeeScript.RESERVED
|
321
|
+
eq nonce, (try CoffeeScript.compile "[#{nonref}...] = v" catch e then nonce)
|
322
|
+
|
323
|
+
test "#1643: splatted accesses in destructuring assignments should not be declared as variables", ->
|
324
|
+
nonce = {}
|
325
|
+
accesses = ['o.a', 'o["a"]', '(o.a)', '(o.a).a', '@o.a', 'C::a', 'C::', 'f().a', 'o?.a', 'o?.a.b', 'f?().a']
|
326
|
+
for access in accesses
|
327
|
+
for i,j in [1,2,3] #position can matter
|
328
|
+
code =
|
329
|
+
"""
|
330
|
+
nonce = {}; nonce2 = {}; nonce3 = {};
|
331
|
+
@o = o = new (class C then a:{}); f = -> o
|
332
|
+
[#{new Array(i).join('x,')}#{access}...] = [#{new Array(i).join('0,')}nonce, nonce2, nonce3]
|
333
|
+
unless #{access}[0] is nonce and #{access}[1] is nonce2 and #{access}[2] is nonce3 then throw new Error('[...]')
|
334
|
+
"""
|
335
|
+
eq nonce, unless (try CoffeeScript.run code, bare: true catch e then true) then nonce
|
336
|
+
# subpatterns like `[[a]...]` and `[{a}...]`
|
337
|
+
subpatterns = ['[sub, sub2, sub3]', '{0: sub, 1: sub2, 2: sub3}']
|
338
|
+
for subpattern in subpatterns
|
339
|
+
for i,j in [1,2,3]
|
340
|
+
code =
|
341
|
+
"""
|
342
|
+
nonce = {}; nonce2 = {}; nonce3 = {};
|
343
|
+
[#{new Array(i).join('x,')}#{subpattern}...] = [#{new Array(i).join('0,')}nonce, nonce2, nonce3]
|
344
|
+
unless sub is nonce and sub2 is nonce2 and sub3 is nonce3 then throw new Error('[sub...]')
|
345
|
+
"""
|
346
|
+
eq nonce, unless (try CoffeeScript.run code, bare: true catch e then true) then nonce
|
347
|
+
|
348
|
+
test "#1838: Regression with variable assignment", ->
|
349
|
+
name =
|
350
|
+
'dave'
|
351
|
+
|
352
|
+
eq name, 'dave'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Boolean Literals
|
2
|
+
# ----------------
|
3
|
+
|
4
|
+
# TODO: add method invocation tests: true.toString() is "true"
|
5
|
+
|
6
|
+
test "#764 Booleans should be indexable", ->
|
7
|
+
toString = Boolean::toString
|
8
|
+
|
9
|
+
eq toString, true['toString']
|
10
|
+
eq toString, false['toString']
|
11
|
+
eq toString, yes['toString']
|
12
|
+
eq toString, no['toString']
|
13
|
+
eq toString, on['toString']
|
14
|
+
eq toString, off['toString']
|
15
|
+
|
16
|
+
eq toString, true.toString
|
17
|
+
eq toString, false.toString
|
18
|
+
eq toString, yes.toString
|
19
|
+
eq toString, no.toString
|
20
|
+
eq toString, on.toString
|
21
|
+
eq toString, off.toString
|
@@ -0,0 +1,681 @@
|
|
1
|
+
# Classes
|
2
|
+
# -------
|
3
|
+
|
4
|
+
# * Class Definition
|
5
|
+
# * Class Instantiation
|
6
|
+
# * Inheritance and Super
|
7
|
+
|
8
|
+
test "classes with a four-level inheritance chain", ->
|
9
|
+
|
10
|
+
class Base
|
11
|
+
func: (string) ->
|
12
|
+
"zero/#{string}"
|
13
|
+
|
14
|
+
@static: (string) ->
|
15
|
+
"static/#{string}"
|
16
|
+
|
17
|
+
class FirstChild extends Base
|
18
|
+
func: (string) ->
|
19
|
+
super('one/') + string
|
20
|
+
|
21
|
+
SecondChild = class extends FirstChild
|
22
|
+
func: (string) ->
|
23
|
+
super('two/') + string
|
24
|
+
|
25
|
+
thirdCtor = ->
|
26
|
+
@array = [1, 2, 3]
|
27
|
+
|
28
|
+
class ThirdChild extends SecondChild
|
29
|
+
constructor: -> thirdCtor.call this
|
30
|
+
|
31
|
+
# Gratuitous comment for testing.
|
32
|
+
func: (string) ->
|
33
|
+
super('three/') + string
|
34
|
+
|
35
|
+
result = (new ThirdChild).func 'four'
|
36
|
+
|
37
|
+
ok result is 'zero/one/two/three/four'
|
38
|
+
ok Base.static('word') is 'static/word'
|
39
|
+
|
40
|
+
FirstChild::func = (string) ->
|
41
|
+
super('one/').length + string
|
42
|
+
|
43
|
+
result = (new ThirdChild).func 'four'
|
44
|
+
|
45
|
+
ok result is '9two/three/four'
|
46
|
+
|
47
|
+
ok (new ThirdChild).array.join(' ') is '1 2 3'
|
48
|
+
|
49
|
+
|
50
|
+
test "constructors with inheritance and super", ->
|
51
|
+
|
52
|
+
identity = (f) -> f
|
53
|
+
|
54
|
+
class TopClass
|
55
|
+
constructor: (arg) ->
|
56
|
+
@prop = 'top-' + arg
|
57
|
+
|
58
|
+
class SuperClass extends TopClass
|
59
|
+
constructor: (arg) ->
|
60
|
+
identity super 'super-' + arg
|
61
|
+
|
62
|
+
class SubClass extends SuperClass
|
63
|
+
constructor: ->
|
64
|
+
identity super 'sub'
|
65
|
+
|
66
|
+
ok (new SubClass).prop is 'top-super-sub'
|
67
|
+
|
68
|
+
|
69
|
+
test "Overriding the static property new doesn't clobber Function::new", ->
|
70
|
+
|
71
|
+
class OneClass
|
72
|
+
@new: 'new'
|
73
|
+
function: 'function'
|
74
|
+
constructor: (name) -> @name = name
|
75
|
+
|
76
|
+
class TwoClass extends OneClass
|
77
|
+
delete TwoClass.new
|
78
|
+
|
79
|
+
Function.prototype.new = -> new this arguments...
|
80
|
+
|
81
|
+
ok (TwoClass.new('three')).name is 'three'
|
82
|
+
ok (new OneClass).function is 'function'
|
83
|
+
ok OneClass.new is 'new'
|
84
|
+
|
85
|
+
delete Function.prototype.new
|
86
|
+
|
87
|
+
|
88
|
+
test "basic classes, again, but in the manual prototype style", ->
|
89
|
+
|
90
|
+
Base = ->
|
91
|
+
Base::func = (string) ->
|
92
|
+
'zero/' + string
|
93
|
+
Base::['func-func'] = (string) ->
|
94
|
+
"dynamic-#{string}"
|
95
|
+
|
96
|
+
FirstChild = ->
|
97
|
+
SecondChild = ->
|
98
|
+
ThirdChild = ->
|
99
|
+
@array = [1, 2, 3]
|
100
|
+
this
|
101
|
+
|
102
|
+
ThirdChild extends SecondChild extends FirstChild extends Base
|
103
|
+
|
104
|
+
FirstChild::func = (string) ->
|
105
|
+
super('one/') + string
|
106
|
+
|
107
|
+
SecondChild::func = (string) ->
|
108
|
+
super('two/') + string
|
109
|
+
|
110
|
+
ThirdChild::func = (string) ->
|
111
|
+
super('three/') + string
|
112
|
+
|
113
|
+
result = (new ThirdChild).func 'four'
|
114
|
+
|
115
|
+
ok result is 'zero/one/two/three/four'
|
116
|
+
|
117
|
+
ok (new ThirdChild)['func-func']('thing') is 'dynamic-thing'
|
118
|
+
|
119
|
+
|
120
|
+
test "super with plain ol' functions as the original constructors", ->
|
121
|
+
|
122
|
+
TopClass = (arg) ->
|
123
|
+
@prop = 'top-' + arg
|
124
|
+
this
|
125
|
+
|
126
|
+
SuperClass = (arg) ->
|
127
|
+
super 'super-' + arg
|
128
|
+
this
|
129
|
+
|
130
|
+
SubClass = ->
|
131
|
+
super 'sub'
|
132
|
+
this
|
133
|
+
|
134
|
+
SuperClass extends TopClass
|
135
|
+
SubClass extends SuperClass
|
136
|
+
|
137
|
+
ok (new SubClass).prop is 'top-super-sub'
|
138
|
+
|
139
|
+
|
140
|
+
test "'@' referring to the current instance, and not being coerced into a call", ->
|
141
|
+
|
142
|
+
class ClassName
|
143
|
+
amI: ->
|
144
|
+
@ instanceof ClassName
|
145
|
+
|
146
|
+
obj = new ClassName
|
147
|
+
ok obj.amI()
|
148
|
+
|
149
|
+
|
150
|
+
test "super() calls in constructors of classes that are defined as object properties", ->
|
151
|
+
|
152
|
+
class Hive
|
153
|
+
constructor: (name) -> @name = name
|
154
|
+
|
155
|
+
class Hive.Bee extends Hive
|
156
|
+
constructor: (name) -> super
|
157
|
+
|
158
|
+
maya = new Hive.Bee 'Maya'
|
159
|
+
ok maya.name is 'Maya'
|
160
|
+
|
161
|
+
|
162
|
+
test "classes with JS-keyword properties", ->
|
163
|
+
|
164
|
+
class Class
|
165
|
+
class: 'class'
|
166
|
+
name: -> @class
|
167
|
+
|
168
|
+
instance = new Class
|
169
|
+
ok instance.class is 'class'
|
170
|
+
ok instance.name() is 'class'
|
171
|
+
|
172
|
+
|
173
|
+
test "Classes with methods that are pre-bound to the instance, or statically, to the class", ->
|
174
|
+
|
175
|
+
class Dog
|
176
|
+
constructor: (name) ->
|
177
|
+
@name = name
|
178
|
+
|
179
|
+
bark: =>
|
180
|
+
"#{@name} woofs!"
|
181
|
+
|
182
|
+
@static = =>
|
183
|
+
new this('Dog')
|
184
|
+
|
185
|
+
spark = new Dog('Spark')
|
186
|
+
fido = new Dog('Fido')
|
187
|
+
fido.bark = spark.bark
|
188
|
+
|
189
|
+
ok fido.bark() is 'Spark woofs!'
|
190
|
+
|
191
|
+
obj = func: Dog.static
|
192
|
+
|
193
|
+
ok obj.func().name is 'Dog'
|
194
|
+
|
195
|
+
|
196
|
+
test "a bound function in a bound function", ->
|
197
|
+
|
198
|
+
class Mini
|
199
|
+
num: 10
|
200
|
+
generate: =>
|
201
|
+
for i in [1..3]
|
202
|
+
=>
|
203
|
+
@num
|
204
|
+
|
205
|
+
m = new Mini
|
206
|
+
eq (func() for func in m.generate()).join(' '), '10 10 10'
|
207
|
+
|
208
|
+
|
209
|
+
test "contructor called with varargs", ->
|
210
|
+
|
211
|
+
class Connection
|
212
|
+
constructor: (one, two, three) ->
|
213
|
+
[@one, @two, @three] = [one, two, three]
|
214
|
+
|
215
|
+
out: ->
|
216
|
+
"#{@one}-#{@two}-#{@three}"
|
217
|
+
|
218
|
+
list = [3, 2, 1]
|
219
|
+
conn = new Connection list...
|
220
|
+
ok conn instanceof Connection
|
221
|
+
ok conn.out() is '3-2-1'
|
222
|
+
|
223
|
+
|
224
|
+
test "calling super and passing along all arguments", ->
|
225
|
+
|
226
|
+
class Parent
|
227
|
+
method: (args...) -> @args = args
|
228
|
+
|
229
|
+
class Child extends Parent
|
230
|
+
method: -> super
|
231
|
+
|
232
|
+
c = new Child
|
233
|
+
c.method 1, 2, 3, 4
|
234
|
+
ok c.args.join(' ') is '1 2 3 4'
|
235
|
+
|
236
|
+
|
237
|
+
test "classes wrapped in decorators", ->
|
238
|
+
|
239
|
+
func = (klass) ->
|
240
|
+
klass::prop = 'value'
|
241
|
+
klass
|
242
|
+
|
243
|
+
func class Test
|
244
|
+
prop2: 'value2'
|
245
|
+
|
246
|
+
ok (new Test).prop is 'value'
|
247
|
+
ok (new Test).prop2 is 'value2'
|
248
|
+
|
249
|
+
|
250
|
+
test "anonymous classes", ->
|
251
|
+
|
252
|
+
obj =
|
253
|
+
klass: class
|
254
|
+
method: -> 'value'
|
255
|
+
|
256
|
+
instance = new obj.klass
|
257
|
+
ok instance.method() is 'value'
|
258
|
+
|
259
|
+
|
260
|
+
test "Implicit objects as static properties", ->
|
261
|
+
|
262
|
+
class Static
|
263
|
+
@static =
|
264
|
+
one: 1
|
265
|
+
two: 2
|
266
|
+
|
267
|
+
ok Static.static.one is 1
|
268
|
+
ok Static.static.two is 2
|
269
|
+
|
270
|
+
|
271
|
+
test "nothing classes", ->
|
272
|
+
|
273
|
+
c = class
|
274
|
+
ok c instanceof Function
|
275
|
+
|
276
|
+
|
277
|
+
test "classes with static-level implicit objects", ->
|
278
|
+
|
279
|
+
class A
|
280
|
+
@static = one: 1
|
281
|
+
two: 2
|
282
|
+
|
283
|
+
class B
|
284
|
+
@static = one: 1,
|
285
|
+
two: 2
|
286
|
+
|
287
|
+
eq A.static.one, 1
|
288
|
+
eq A.static.two, undefined
|
289
|
+
eq (new A).two, 2
|
290
|
+
|
291
|
+
eq B.static.one, 1
|
292
|
+
eq B.static.two, 2
|
293
|
+
eq (new B).two, undefined
|
294
|
+
|
295
|
+
|
296
|
+
test "classes with value'd constructors", ->
|
297
|
+
|
298
|
+
counter = 0
|
299
|
+
classMaker = ->
|
300
|
+
inner = ++counter
|
301
|
+
->
|
302
|
+
@value = inner
|
303
|
+
|
304
|
+
class One
|
305
|
+
constructor: classMaker()
|
306
|
+
|
307
|
+
class Two
|
308
|
+
constructor: classMaker()
|
309
|
+
|
310
|
+
eq (new One).value, 1
|
311
|
+
eq (new Two).value, 2
|
312
|
+
eq (new One).value, 1
|
313
|
+
eq (new Two).value, 2
|
314
|
+
|
315
|
+
|
316
|
+
test "exectuable class bodies", ->
|
317
|
+
|
318
|
+
class A
|
319
|
+
if true
|
320
|
+
b: 'b'
|
321
|
+
else
|
322
|
+
c: 'c'
|
323
|
+
|
324
|
+
a = new A
|
325
|
+
|
326
|
+
eq a.b, 'b'
|
327
|
+
eq a.c, undefined
|
328
|
+
|
329
|
+
|
330
|
+
test "mild metaprogramming", ->
|
331
|
+
|
332
|
+
class Base
|
333
|
+
@attr: (name) ->
|
334
|
+
@::[name] = (val) ->
|
335
|
+
if arguments.length > 0
|
336
|
+
@["_#{name}"] = val
|
337
|
+
else
|
338
|
+
@["_#{name}"]
|
339
|
+
|
340
|
+
class Robot extends Base
|
341
|
+
@attr 'power'
|
342
|
+
@attr 'speed'
|
343
|
+
|
344
|
+
robby = new Robot
|
345
|
+
|
346
|
+
ok robby.power() is undefined
|
347
|
+
|
348
|
+
robby.power 11
|
349
|
+
robby.speed Infinity
|
350
|
+
|
351
|
+
eq robby.power(), 11
|
352
|
+
eq robby.speed(), Infinity
|
353
|
+
|
354
|
+
|
355
|
+
test "namespaced classes do not reserve their function name in outside scope", ->
|
356
|
+
|
357
|
+
one = {}
|
358
|
+
two = {}
|
359
|
+
|
360
|
+
class one.Klass
|
361
|
+
@label = "one"
|
362
|
+
|
363
|
+
class two.Klass
|
364
|
+
@label = "two"
|
365
|
+
|
366
|
+
eq typeof Klass, 'undefined'
|
367
|
+
eq one.Klass.label, 'one'
|
368
|
+
eq two.Klass.label, 'two'
|
369
|
+
|
370
|
+
|
371
|
+
test "nested classes", ->
|
372
|
+
|
373
|
+
class Outer
|
374
|
+
constructor: ->
|
375
|
+
@label = 'outer'
|
376
|
+
|
377
|
+
class @Inner
|
378
|
+
constructor: ->
|
379
|
+
@label = 'inner'
|
380
|
+
|
381
|
+
eq (new Outer).label, 'outer'
|
382
|
+
eq (new Outer.Inner).label, 'inner'
|
383
|
+
|
384
|
+
|
385
|
+
test "variables in constructor bodies are correctly scoped", ->
|
386
|
+
|
387
|
+
class A
|
388
|
+
x = 1
|
389
|
+
constructor: ->
|
390
|
+
x = 10
|
391
|
+
y = 20
|
392
|
+
y = 2
|
393
|
+
captured: ->
|
394
|
+
{x, y}
|
395
|
+
|
396
|
+
a = new A
|
397
|
+
eq a.captured().x, 10
|
398
|
+
eq a.captured().y, 2
|
399
|
+
|
400
|
+
|
401
|
+
test "Issue #924: Static methods in nested classes", ->
|
402
|
+
|
403
|
+
class A
|
404
|
+
@B: class
|
405
|
+
@c = -> 5
|
406
|
+
|
407
|
+
eq A.B.c(), 5
|
408
|
+
|
409
|
+
|
410
|
+
test "`class extends this`", ->
|
411
|
+
|
412
|
+
class A
|
413
|
+
func: -> 'A'
|
414
|
+
|
415
|
+
B = null
|
416
|
+
makeClass = ->
|
417
|
+
B = class extends this
|
418
|
+
func: -> super + ' B'
|
419
|
+
|
420
|
+
makeClass.call A
|
421
|
+
|
422
|
+
eq (new B()).func(), 'A B'
|
423
|
+
|
424
|
+
|
425
|
+
test "ensure that constructors invoked with splats return a new object", ->
|
426
|
+
|
427
|
+
args = [1, 2, 3]
|
428
|
+
Type = (@args) ->
|
429
|
+
type = new Type args
|
430
|
+
|
431
|
+
ok type and type instanceof Type
|
432
|
+
ok type.args and type.args instanceof Array
|
433
|
+
ok v is args[i] for v, i in type.args
|
434
|
+
|
435
|
+
Type1 = (@a, @b, @c) ->
|
436
|
+
type1 = new Type1 args...
|
437
|
+
|
438
|
+
ok type1 instanceof Type1
|
439
|
+
eq type1.constructor, Type1
|
440
|
+
ok type1.a is args[0] and type1.b is args[1] and type1.c is args[2]
|
441
|
+
|
442
|
+
# Ensure that constructors invoked with splats cache the function.
|
443
|
+
called = 0
|
444
|
+
get = -> if called++ then false else class Type
|
445
|
+
new get() args...
|
446
|
+
|
447
|
+
test "`new` shouldn't add extra parens", ->
|
448
|
+
|
449
|
+
ok new Date().constructor is Date
|
450
|
+
|
451
|
+
|
452
|
+
test "`new` works against bare function", ->
|
453
|
+
|
454
|
+
eq Date, new ->
|
455
|
+
eq this, new => this
|
456
|
+
Date
|
457
|
+
|
458
|
+
|
459
|
+
test "#1182: a subclass should be able to set its constructor to an external function", ->
|
460
|
+
ctor = ->
|
461
|
+
@val = 1
|
462
|
+
class A
|
463
|
+
class B extends A
|
464
|
+
constructor: ctor
|
465
|
+
eq (new B).val, 1
|
466
|
+
|
467
|
+
test "#1182: external constructors continued", ->
|
468
|
+
ctor = ->
|
469
|
+
class A
|
470
|
+
class B extends A
|
471
|
+
method: ->
|
472
|
+
constructor: ctor
|
473
|
+
ok B::method
|
474
|
+
|
475
|
+
test "#1313: misplaced __extends", ->
|
476
|
+
nonce = {}
|
477
|
+
class A
|
478
|
+
class B extends A
|
479
|
+
prop: nonce
|
480
|
+
constructor: ->
|
481
|
+
eq nonce, B::prop
|
482
|
+
|
483
|
+
test "#1182: execution order needs to be considered as well", ->
|
484
|
+
counter = 0
|
485
|
+
makeFn = (n) -> eq n, ++counter; ->
|
486
|
+
class B extends (makeFn 1)
|
487
|
+
@B: makeFn 2
|
488
|
+
constructor: makeFn 3
|
489
|
+
|
490
|
+
test "#1182: external constructors with bound functions", ->
|
491
|
+
fn = ->
|
492
|
+
{one: 1}
|
493
|
+
this
|
494
|
+
class B
|
495
|
+
class A
|
496
|
+
constructor: fn
|
497
|
+
method: => this instanceof A
|
498
|
+
ok (new A).method.call(new B)
|
499
|
+
|
500
|
+
test "#1372: bound class methods with reserved names", ->
|
501
|
+
class C
|
502
|
+
delete: =>
|
503
|
+
ok C::delete
|
504
|
+
|
505
|
+
test "#1380: `super` with reserved names", ->
|
506
|
+
class C
|
507
|
+
do: -> super
|
508
|
+
ok C::do
|
509
|
+
|
510
|
+
class B
|
511
|
+
0: -> super
|
512
|
+
ok B::[0]
|
513
|
+
|
514
|
+
test "#1464: bound class methods should keep context", ->
|
515
|
+
nonce = {}
|
516
|
+
nonce2 = {}
|
517
|
+
class C
|
518
|
+
constructor: (@id) ->
|
519
|
+
@boundStaticColon: => new this(nonce)
|
520
|
+
@boundStaticEqual= => new this(nonce2)
|
521
|
+
eq nonce, C.boundStaticColon().id
|
522
|
+
eq nonce2, C.boundStaticEqual().id
|
523
|
+
|
524
|
+
test "#1009: classes with reserved words as determined names", -> (->
|
525
|
+
eq 'function', typeof (class @for)
|
526
|
+
ok not /\beval\b/.test (class @eval).toString()
|
527
|
+
ok not /\barguments\b/.test (class @arguments).toString()
|
528
|
+
).call {}
|
529
|
+
|
530
|
+
test "#1482: classes can extend expressions", ->
|
531
|
+
id = (x) -> x
|
532
|
+
nonce = {}
|
533
|
+
class A then nonce: nonce
|
534
|
+
class B extends id A
|
535
|
+
eq nonce, (new B).nonce
|
536
|
+
|
537
|
+
test "#1598: super works for static methods too", ->
|
538
|
+
|
539
|
+
class Parent
|
540
|
+
method: ->
|
541
|
+
'NO'
|
542
|
+
@method: ->
|
543
|
+
'yes'
|
544
|
+
|
545
|
+
class Child extends Parent
|
546
|
+
@method: ->
|
547
|
+
'pass? ' + super
|
548
|
+
|
549
|
+
eq Child.method(), 'pass? yes'
|
550
|
+
|
551
|
+
test "#1842: Regression with bound functions within bound class methods", ->
|
552
|
+
|
553
|
+
class Store
|
554
|
+
@bound: =>
|
555
|
+
do =>
|
556
|
+
eq this, Store
|
557
|
+
|
558
|
+
Store.bound()
|
559
|
+
|
560
|
+
# And a fancier case:
|
561
|
+
|
562
|
+
class Store
|
563
|
+
|
564
|
+
eq this, Store
|
565
|
+
|
566
|
+
@bound: =>
|
567
|
+
do =>
|
568
|
+
eq this, Store
|
569
|
+
|
570
|
+
@unbound: ->
|
571
|
+
eq this, Store
|
572
|
+
|
573
|
+
instance: =>
|
574
|
+
ok this instanceof Store
|
575
|
+
|
576
|
+
Store.bound()
|
577
|
+
Store.unbound()
|
578
|
+
(new Store).instance()
|
579
|
+
|
580
|
+
test "#1876: Class @A extends A", ->
|
581
|
+
class A
|
582
|
+
class @A extends A
|
583
|
+
|
584
|
+
ok (new @A) instanceof A
|
585
|
+
|
586
|
+
test "#1813: Passing class definitions as expressions", ->
|
587
|
+
ident = (x) -> x
|
588
|
+
|
589
|
+
result = ident class A then x = 1
|
590
|
+
|
591
|
+
eq result, A
|
592
|
+
|
593
|
+
result = ident class B extends A
|
594
|
+
x = 1
|
595
|
+
|
596
|
+
eq result, B
|
597
|
+
|
598
|
+
test "#494: Named classes", ->
|
599
|
+
|
600
|
+
class A
|
601
|
+
eq A.name, 'A'
|
602
|
+
|
603
|
+
class A.B
|
604
|
+
eq A.B.name, 'B'
|
605
|
+
|
606
|
+
class A.B["C"]
|
607
|
+
ok A.B.C.name isnt 'C'
|
608
|
+
|
609
|
+
test "#1966: external constructors should produce their return value", ->
|
610
|
+
ctor = -> {}
|
611
|
+
class A then constructor: ctor
|
612
|
+
ok (new A) not instanceof A
|
613
|
+
|
614
|
+
test "#1980: regression with an inherited class with static function members", ->
|
615
|
+
|
616
|
+
class A
|
617
|
+
|
618
|
+
class B extends A
|
619
|
+
@static: => 'value'
|
620
|
+
|
621
|
+
eq B.static(), 'value'
|
622
|
+
|
623
|
+
test "#1534: class then 'use strict'", ->
|
624
|
+
# [14.1 Directive Prologues and the Use Strict Directive](http://es5.github.com/#x14.1)
|
625
|
+
nonce = {}
|
626
|
+
error = 'do -> ok this'
|
627
|
+
strictTest = "do ->'use strict';#{error}"
|
628
|
+
return unless (try CoffeeScript.run strictTest, bare: yes catch e then nonce) is nonce
|
629
|
+
|
630
|
+
throws -> CoffeeScript.run "class then 'use strict';#{error}", bare: yes
|
631
|
+
doesNotThrow -> CoffeeScript.run "class then #{error}", bare: yes
|
632
|
+
doesNotThrow -> CoffeeScript.run "class then #{error};'use strict'", bare: yes
|
633
|
+
|
634
|
+
# comments are ignored in the Directive Prologue
|
635
|
+
comments = ["""
|
636
|
+
class
|
637
|
+
### comment ###
|
638
|
+
'use strict'
|
639
|
+
#{error}""",
|
640
|
+
"""
|
641
|
+
class
|
642
|
+
### comment 1 ###
|
643
|
+
### comment 2 ###
|
644
|
+
'use strict'
|
645
|
+
#{error}""",
|
646
|
+
"""
|
647
|
+
class
|
648
|
+
### comment 1 ###
|
649
|
+
### comment 2 ###
|
650
|
+
'use strict'
|
651
|
+
#{error}
|
652
|
+
### comment 3 ###"""
|
653
|
+
]
|
654
|
+
throws (-> CoffeeScript.run comment, bare: yes) for comment in comments
|
655
|
+
|
656
|
+
# [ES5 §14.1](http://es5.github.com/#x14.1) allows for other directives
|
657
|
+
directives = ["""
|
658
|
+
class
|
659
|
+
'directive 1'
|
660
|
+
'use strict'
|
661
|
+
#{error}""",
|
662
|
+
"""
|
663
|
+
class
|
664
|
+
'use strict'
|
665
|
+
'directive 2'
|
666
|
+
#{error}""",
|
667
|
+
"""
|
668
|
+
class
|
669
|
+
### comment 1 ###
|
670
|
+
'directive 1'
|
671
|
+
'use strict'
|
672
|
+
#{error}""",
|
673
|
+
"""
|
674
|
+
class
|
675
|
+
### comment 1 ###
|
676
|
+
'directive 1'
|
677
|
+
### comment 2 ###
|
678
|
+
'use strict'
|
679
|
+
#{error}"""
|
680
|
+
]
|
681
|
+
throws (-> CoffeeScript.run directive, bare: yes) for directive in directives
|