@@ -211,3 +211,191 @@ test "#2916: block comment before implicit call with implicit object", ->
211211 ### ###
212212 fn
213213 a : yes
214+
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+
227+ test " #3132: Format multi-line block comment nicely" , ->
228+ input = """
229+ ###
230+ # Multi-line
231+ # block
232+ # comment
233+ ###"""
234+
235+ result = """
236+
237+ /*
238+ * Multi-line
239+ * block
240+ * comment
241+ */
242+
243+
244+ """
245+ eq CoffeeScript .compile (input, bare : on ), result
246+
247+ test " #3132: Format simple block comment nicely" , ->
248+ input = """
249+ ###
250+ No
251+ Preceding hash
252+ ###"""
253+
254+ result = """
255+
256+ /*
257+ No
258+ Preceding hash
259+ */
260+
261+
262+ """
263+
264+ eq CoffeeScript .compile (input, bare : on ), result
265+
266+ test " #3132: Format indented block-comment nicely" , ->
267+ input = """
268+ fn = () ->
269+ ###
270+ # Indented
271+ Multiline
272+ ###
273+ 1"""
274+
275+ result = """
276+ var fn;
277+
278+ fn = function() {
279+
280+ /*
281+ * Indented
282+ Multiline
283+ */
284+ return 1;
285+ };
286+
287+ """
288+ 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