Skip to content

Commit

Permalink
Merge pull request jashkenas#1 from sjorek/issue-3132
Browse files Browse the repository at this point in the history
Enhancement: Add more block-comment related tests
  • Loading branch information
Caitlin Potter committed Sep 17, 2013
2 parents 1b7491d + 89f5f9d commit 359e172
Showing 1 changed file with 125 additions and 0 deletions.
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

0 comments on commit 359e172

Please sign in to comment.