jashkenas--coffeescript/test/test_comments.coffee

157 lines
1.4 KiB
CoffeeScript
Raw Normal View History

# comment before a ...
###
... block comment.
###
2010-01-06 04:15:32 +00:00
# comment
2010-07-25 05:23:37 +00:00
func = ->
2010-01-06 04:15:32 +00:00
# comment
false
false # comment
false
# comment
true
2010-01-06 04:15:32 +00:00
2010-01-10 22:36:06 +00:00
switch 'string'
# comment
when false then something()
# comment
when null
somethingElse()
2010-01-10 22:36:06 +00:00
->
code()
# comment
ok func()
func
func
# Line3
2010-07-25 05:23:37 +00:00
obj = {
# comment
# comment
# comment
one: 1
# comment
two: 2
# comment
}
2010-07-25 05:23:37 +00:00
result = if true # comment
false
ok not result
2010-07-25 05:23:37 +00:00
result = if false
false
else # comment
45
ok result is 45
2010-07-25 05:23:37 +00:00
test =
'test ' +
'test ' + # comment
'test'
ok test is 'test test test'
###
This is a here-comment.
Kind of like a heredoc.
###
2010-07-25 05:23:37 +00:00
func = ->
###
Another block comment.
###
code
2010-07-25 05:23:37 +00:00
func = ->
one = ->
two = ->
three = ->
###
block.
###
2010-07-25 05:23:37 +00:00
four = ->
2010-07-25 05:23:37 +00:00
fn1 = ->
oneLevel = null
###
This isn't fine.
###
ok ok
2010-07-25 05:23:37 +00:00
obj = {
a: 'b'
###
comment
###
c: 'd'
}
2010-07-25 05:23:37 +00:00
arr = [
1, 2, 3,
###
four
###
5, 6, 7
]
# Spaced comments in if / elses.
2010-07-25 05:23:37 +00:00
result = if false
1
# comment
else if false
2
# comment
else
3
ok result is 3
2010-07-25 05:23:37 +00:00
result = switch 'z'
when 'z' then 7
# comment
ok result is 7
# Trailing-line comment before an outdent.
2010-07-25 05:23:37 +00:00
func = ->
if true
true # comment
7
ok func() is 7
# Trailing herecomment in a function.
2010-07-25 05:23:37 +00:00
fn = ->
code
###
debug code commented
###
2010-07-25 05:23:37 +00:00
fn2 = ->
class A
b: ->
###
Comment
###
c: ->
ok A.prototype.c instanceof Function