Skip to content

Commit 359e172

Browse files
author
Caitlin Potter
committed
Merge pull request jashkenas#1 from sjorek/issue-3132
Enhancement: Add more block-comment related tests
2 parents 1b7491d + 89f5f9d commit 359e172

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

test/comments.coffee

+125
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,18 @@ test "#2916: block comment before implicit call with implicit object", ->
212212
fn
213213
a: yes
214214

215+
test "#3132: Format single-line block comment nicely", ->
216+
input = """
217+
### Single-line block comment without additional space here => ###"""
218+
219+
result = """
220+
221+
/* Single-line block comment without additional space here => */
222+
223+
224+
"""
225+
eq CoffeeScript.compile(input, bare: on), result
226+
215227
test "#3132: Format multi-line block comment nicely", ->
216228
input = """
217229
###
@@ -274,3 +286,116 @@ test "#3132: Format indented block-comment nicely", ->
274286
275287
"""
276288
eq CoffeeScript.compile(input, bare: on), result
289+
290+
# Although adequately working, block comment-placement is not yet perfect.
291+
# (Considering a case where multiple variables have been declared …)
292+
test "#3132: Format jsdoc-style block-comment nicely", ->
293+
input = """
294+
###*
295+
# Multiline for jsdoc-"@doctags"
296+
#
297+
# @type {Function}
298+
###
299+
fn = () -> 1
300+
"""
301+
302+
result = """
303+
304+
/**
305+
* Multiline for jsdoc-"@doctags"
306+
*
307+
* @type {Function}
308+
*/
309+
var fn;
310+
311+
fn = function() {
312+
return 1;
313+
};
314+
315+
"""
316+
eq CoffeeScript.compile(input, bare: on), result
317+
318+
# Although adequately working, block comment-placement is not yet perfect.
319+
# (Considering a case where multiple variables have been declared …)
320+
test "#3132: Format hand-made (raw) jsdoc-style block-comment nicely", ->
321+
input = """
322+
###*
323+
* Multiline for jsdoc-"@doctags"
324+
*
325+
* @type {Function}
326+
###
327+
fn = () -> 1
328+
"""
329+
330+
result = """
331+
332+
/**
333+
* Multiline for jsdoc-"@doctags"
334+
*
335+
* @type {Function}
336+
*/
337+
var fn;
338+
339+
fn = function() {
340+
return 1;
341+
};
342+
343+
"""
344+
eq CoffeeScript.compile(input, bare: on), result
345+
346+
# Although adequately working, block comment-placement is not yet perfect.
347+
# (Considering a case where multiple variables have been declared …)
348+
test "#3132: Place block-comments nicely", ->
349+
input = """
350+
###*
351+
# A dummy class definition
352+
#
353+
# @class
354+
###
355+
class DummyClass
356+
357+
###*
358+
# @constructor
359+
###
360+
constructor: ->
361+
362+
###*
363+
# Singleton reference
364+
#
365+
# @type {DummyClass}
366+
###
367+
@instance = new DummyClass()
368+
369+
"""
370+
371+
result = """
372+
373+
/**
374+
* A dummy class definition
375+
*
376+
* @class
377+
*/
378+
var DummyClass;
379+
380+
DummyClass = (function() {
381+
382+
/**
383+
* @constructor
384+
*/
385+
function DummyClass() {}
386+
387+
388+
/**
389+
* Singleton reference
390+
*
391+
* @type {DummyClass}
392+
*/
393+
394+
DummyClass.instance = new DummyClass();
395+
396+
return DummyClass;
397+
398+
})();
399+
400+
"""
401+
eq CoffeeScript.compile(input, bare: on), result

0 commit comments

Comments
 (0)