2010-10-11 18:22:01 -04:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
|
|
|
<title>CoffeeScript Test Suite</title>
|
|
|
|
<script src="../extras/coffee-script.js"></script>
|
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
margin: 30px;
|
|
|
|
font-family: Menlo, Monaco, monospace;
|
|
|
|
}
|
|
|
|
h1 {
|
|
|
|
font-size: 20px;
|
|
|
|
}
|
|
|
|
#stdout {
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<h1>CoffeeScript Test Suite</h1>
|
|
|
|
<pre id="stdout"></pre>
|
|
|
|
|
|
|
|
<script type="text/coffeescript">
|
|
|
|
|
|
|
|
stdout = document.getElementById 'stdout'
|
|
|
|
start = new Date
|
|
|
|
success = total = done = failed = 0
|
|
|
|
|
2011-05-01 08:28:00 -04:00
|
|
|
say = (msg) ->
|
2010-10-11 18:22:01 -04:00
|
|
|
div = document.createElement 'div'
|
|
|
|
div.appendChild document.createTextNode msg
|
|
|
|
stdout.appendChild div
|
|
|
|
msg
|
|
|
|
|
2010-12-16 00:12:11 -05:00
|
|
|
@test = (desc, fn) ->
|
2010-12-12 21:41:04 -05:00
|
|
|
fn()
|
|
|
|
|
2010-12-16 00:12:11 -05:00
|
|
|
@ok = (good, msg) ->
|
2010-10-11 18:22:01 -04:00
|
|
|
++total
|
|
|
|
if good then ++success else throw Error say msg
|
|
|
|
|
2010-12-16 00:12:11 -05:00
|
|
|
@eq = (x, y, msg) -> ok x is y, msg ? x + ' !== ' + y
|
2010-10-11 18:22:01 -04:00
|
|
|
|
2010-12-22 21:34:36 -05:00
|
|
|
arrayEqual = (a, b) ->
|
2010-12-16 00:12:11 -05:00
|
|
|
if a is b
|
|
|
|
# 0 isnt -0
|
|
|
|
a isnt 0 or 1/a is 1/b
|
|
|
|
else if a instanceof Array and b instanceof Array
|
|
|
|
return no unless a.length is b.length
|
|
|
|
return no for el, idx in a when not arrayEq el, b[idx]
|
|
|
|
yes
|
2010-12-13 06:28:17 -05:00
|
|
|
else
|
2010-12-16 00:12:11 -05:00
|
|
|
# NaN is NaN
|
|
|
|
a isnt a and b isnt b
|
|
|
|
|
2010-12-22 21:34:36 -05:00
|
|
|
@doesNotThrow = (fn) ->
|
2010-12-22 20:10:21 -05:00
|
|
|
fn()
|
|
|
|
ok true
|
|
|
|
|
2010-12-22 21:34:36 -05:00
|
|
|
@arrayEq = (a, b, msg) -> ok arrayEqual(a,b), msg
|
2010-12-13 06:28:17 -05:00
|
|
|
|
2010-12-16 00:12:11 -05:00
|
|
|
@throws = (fun, err, msg) ->
|
2010-12-24 14:02:10 -05:00
|
|
|
try
|
|
|
|
fun()
|
|
|
|
catch e
|
|
|
|
if err
|
|
|
|
eq e, err
|
|
|
|
else
|
|
|
|
ok yes
|
|
|
|
return
|
|
|
|
ok no
|
|
|
|
|
2010-10-11 18:22:01 -04:00
|
|
|
run = (name) ->
|
2011-05-01 08:28:00 -04:00
|
|
|
CoffeeScript.load "#{name}.coffee", ->
|
|
|
|
say '\u2714 ' + name
|
2010-10-11 18:22:01 -04:00
|
|
|
fin() if ++done is names.length
|
|
|
|
|
|
|
|
fin = ->
|
|
|
|
yay = success is total and not failed
|
|
|
|
sec = (new Date - start) / 1000
|
|
|
|
msg = "passed #{success} tests in #{ sec.toFixed 2 } seconds"
|
|
|
|
msg = "failed #{ total - success } tests and #{msg}" unless yay
|
|
|
|
say msg, yay
|
|
|
|
|
|
|
|
run name for name in names = [
|
2011-05-01 08:28:00 -04:00
|
|
|
'arrays'
|
2010-10-11 18:22:01 -04:00
|
|
|
'assignment'
|
2011-05-01 08:28:00 -04:00
|
|
|
'booleans'
|
2011-01-03 04:37:29 -05:00
|
|
|
'classes'
|
2013-02-28 20:51:55 -05:00
|
|
|
'cluster'
|
2010-10-11 18:22:01 -04:00
|
|
|
'comments'
|
2011-01-03 04:37:29 -05:00
|
|
|
'compilation'
|
|
|
|
'comprehensions'
|
|
|
|
'control_flow'
|
2010-12-12 21:41:04 -05:00
|
|
|
'exception_handling'
|
2011-01-03 04:37:29 -05:00
|
|
|
'formatting'
|
|
|
|
'function_invocation'
|
2011-05-01 08:28:00 -04:00
|
|
|
'functions'
|
2010-12-13 06:28:17 -05:00
|
|
|
'helpers'
|
2011-01-03 04:37:29 -05:00
|
|
|
'importing'
|
|
|
|
'interpolation'
|
|
|
|
'javascript_literals'
|
2011-05-01 08:28:00 -04:00
|
|
|
'numbers'
|
|
|
|
'objects'
|
2010-12-12 21:41:04 -05:00
|
|
|
'operators'
|
2011-01-03 04:37:29 -05:00
|
|
|
'option_parser'
|
2011-05-01 08:28:00 -04:00
|
|
|
'ranges'
|
|
|
|
'regexps'
|
2011-01-03 04:37:29 -05:00
|
|
|
'scope'
|
|
|
|
'slicing_and_splicing'
|
|
|
|
'soaks'
|
2011-05-01 08:28:00 -04:00
|
|
|
'strings'
|
2010-10-11 18:22:01 -04:00
|
|
|
]
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
2010-12-13 06:28:17 -05:00
|
|
|
</html>
|