Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions test/comments.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
###
Expand Down Expand Up @@ -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