From 89f5f9d59db0c8e1aff3b4f66de765d339adb44d Mon Sep 17 00:00:00 2001 From: Stephan Jorek Date: Tue, 17 Sep 2013 18:09:15 +0200 Subject: [PATCH] added more block-comment related tests for single-line block-comments and jsdoc-like @doctags-comments. --- test/comments.coffee | 125 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/test/comments.coffee b/test/comments.coffee index 05b17085dd..0b68ee37da 100644 --- a/test/comments.coffee +++ b/test/comments.coffee @@ -212,6 +212,18 @@ test "#2916: block comment before implicit call with implicit object", -> fn a: yes +test "#3132: Format single-line block comment nicely", -> + input = """ + ### Single-line block comment without additional space here => ###""" + + result = """ + + /* Single-line block comment without additional space here => */ + + + """ + eq CoffeeScript.compile(input, bare: on), result + test "#3132: Format multi-line block comment nicely", -> input = """ ### @@ -274,3 +286,116 @@ test "#3132: Format indented block-comment nicely", -> """ eq CoffeeScript.compile(input, bare: on), result + +# Although adequately working, block comment-placement is not yet perfect. +# (Considering a case where multiple variables have been declared …) +test "#3132: Format jsdoc-style block-comment nicely", -> + input = """ + ###* + # Multiline for jsdoc-"@doctags" + # + # @type {Function} + ### + fn = () -> 1 + """ + + result = """ + + /** + * Multiline for jsdoc-"@doctags" + * + * @type {Function} + */ + var fn; + + fn = function() { + return 1; + }; + + """ + eq CoffeeScript.compile(input, bare: on), result + +# Although adequately working, block comment-placement is not yet perfect. +# (Considering a case where multiple variables have been declared …) +test "#3132: Format hand-made (raw) jsdoc-style block-comment nicely", -> + input = """ + ###* + * Multiline for jsdoc-"@doctags" + * + * @type {Function} + ### + fn = () -> 1 + """ + + result = """ + + /** + * Multiline for jsdoc-"@doctags" + * + * @type {Function} + */ + var fn; + + fn = function() { + return 1; + }; + + """ + eq CoffeeScript.compile(input, bare: on), result + +# Although adequately working, block comment-placement is not yet perfect. +# (Considering a case where multiple variables have been declared …) +test "#3132: Place block-comments nicely", -> + input = """ + ###* + # A dummy class definition + # + # @class + ### + class DummyClass + + ###* + # @constructor + ### + constructor: -> + + ###* + # Singleton reference + # + # @type {DummyClass} + ### + @instance = new DummyClass() + + """ + + result = """ + + /** + * A dummy class definition + * + * @class + */ + var DummyClass; + + DummyClass = (function() { + + /** + * @constructor + */ + function DummyClass() {} + + + /** + * Singleton reference + * + * @type {DummyClass} + */ + + DummyClass.instance = new DummyClass(); + + return DummyClass; + + })(); + + """ + eq CoffeeScript.compile(input, bare: on), result