mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
100 lines
1.8 KiB
HTML
100 lines
1.8 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
|
<title>CoffeeScript Test Suite</title>
|
|
<script src="browser-compiler/coffee-script.js"></script>
|
|
<style>
|
|
body, pre {
|
|
font-family: Consolas, Menlo, Monaco, monospace;
|
|
}
|
|
body {
|
|
margin: 1em;
|
|
}
|
|
h1 {
|
|
font-size: 1.3em;
|
|
}
|
|
div {
|
|
margin: 0.6em;
|
|
}
|
|
.good {
|
|
color: #22b24c
|
|
}
|
|
.bad {
|
|
color: #eb6864
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<h1>CoffeeScript Test Suite</h1>
|
|
|
|
<pre id="stdout"></pre>
|
|
|
|
<script type="text/coffeescript">
|
|
@global = window
|
|
stdout = document.getElementById 'stdout'
|
|
desc = ''
|
|
start = new Date
|
|
success = total = done = failed = 0
|
|
|
|
say = (msg, emphasis) ->
|
|
div = document.createElement 'div'
|
|
if emphasis?
|
|
div.className = if emphasis then 'good' else 'bad'
|
|
div.appendChild document.createTextNode msg
|
|
stdout.appendChild div
|
|
msg
|
|
|
|
@test = (description, fn) ->
|
|
desc = description
|
|
fn()
|
|
|
|
@ok = (good, msg) ->
|
|
++total
|
|
if good
|
|
++success
|
|
else
|
|
say "#{desc}:", no
|
|
throw Error say msg, no
|
|
|
|
<%= testHelpers %>
|
|
|
|
@doesNotThrow = (fn) ->
|
|
fn()
|
|
ok true
|
|
|
|
@throws = (fun, err, msg) ->
|
|
try
|
|
fun()
|
|
catch e
|
|
if err
|
|
eq e, err
|
|
else
|
|
ok yes
|
|
return
|
|
ok no
|
|
|
|
# Run the tests
|
|
for test in document.getElementsByClassName 'test'
|
|
say '\u2714 ' + test.id
|
|
try
|
|
options = {}
|
|
options.literate = yes if test.type is 'text/x-literate-coffeescript'
|
|
CoffeeScript.run test.innerHTML
|
|
catch error
|
|
console.error error
|
|
|
|
# Finish up
|
|
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
|
|
</script>
|
|
|
|
<%= tests %>
|
|
|
|
</body>
|
|
</html>
|