2010-10-11 22:22:01 +00: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
|
|
|
|
|
|
|
|
say = (msg, yay) ->
|
|
|
|
div = document.createElement 'div'
|
|
|
|
div.appendChild document.createTextNode msg
|
|
|
|
div.style.color = if yay then 'green' else 'red'
|
|
|
|
stdout.appendChild div
|
|
|
|
msg
|
|
|
|
|
2010-12-13 02:41:04 +00:00
|
|
|
this.test = (desc, fn) ->
|
|
|
|
fn()
|
|
|
|
|
2010-10-11 22:22:01 +00:00
|
|
|
this.ok = (good, msg) ->
|
|
|
|
++total
|
|
|
|
if good then ++success else throw Error say msg
|
|
|
|
|
|
|
|
this.eq = (x, y, msg) -> ok x is y, msg ? x + ' !== ' + y
|
|
|
|
|
|
|
|
this.throws = (fun, err, msg) ->
|
|
|
|
try fun(); throw new String 'No Error'
|
|
|
|
catch e then eq e, err
|
|
|
|
|
|
|
|
CoffeeScript.run = (code, cb) ->
|
|
|
|
try Function(CoffeeScript.compile code, wrap: no)()
|
|
|
|
catch e then cb(); throw e
|
|
|
|
cb yes
|
|
|
|
|
|
|
|
run = (name) ->
|
2010-12-13 02:41:04 +00:00
|
|
|
CoffeeScript.load "#{name}.coffee", (yay) ->
|
2010-10-11 22:22:01 +00:00
|
|
|
say "#{ if yay then '\u2714' else '\u3000' } #{name}", yay
|
|
|
|
++failed unless yay
|
|
|
|
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 = [
|
|
|
|
'arguments'
|
|
|
|
'assignment'
|
|
|
|
'break'
|
|
|
|
'comments'
|
2010-12-13 02:41:04 +00:00
|
|
|
'exception_handling'
|
|
|
|
'operators'
|
|
|
|
'regular_expressions'
|
|
|
|
'test_chaining'
|
|
|
|
'test_classes'
|
|
|
|
'test_compilation'
|
|
|
|
'test_comprehensions'
|
|
|
|
'test_existence'
|
|
|
|
'test_functions'
|
|
|
|
'test_helpers'
|
|
|
|
'test_heredocs'
|
|
|
|
'test_if'
|
|
|
|
'test_literals'
|
|
|
|
'test_pattern_matching'
|
|
|
|
'test_ranges_slices_and_splices'
|
|
|
|
'test_returns'
|
|
|
|
'test_splats'
|
|
|
|
'test_strings'
|
|
|
|
'test_switch'
|
|
|
|
'test_while'
|
2010-10-11 22:22:01 +00:00
|
|
|
]
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|