fixing test.html

This commit is contained in:
Jeremy Ashkenas 2011-05-01 08:28:00 -04:00
parent 43ebec1812
commit 5fd82e829b
5 changed files with 17 additions and 26 deletions

File diff suppressed because one or more lines are too long

View File

@ -23,8 +23,9 @@
xhr.overrideMimeType('text/plain');
}
xhr.onreadystatechange = function() {
var _ref;
if (xhr.readyState === 4) {
if (xhr.status === 200) {
if ((_ref = xhr.status) === 0 || _ref === 200) {
CoffeeScript.run(xhr.responseText);
} else {
throw new Error("Could not load " + url);

View File

@ -22,11 +22,11 @@ CoffeeScript.load = (url, callback) ->
xhr.overrideMimeType 'text/plain' if 'overrideMimeType' of xhr
xhr.onreadystatechange = ->
if xhr.readyState is 4
if xhr.status is 200
if xhr.status in [0, 200]
CoffeeScript.run xhr.responseText
else
throw new Error "Could not load #{url}"
callback() if callback
callback() if callback
xhr.send null
# Activate CoffeeScript in the browser by having it compile and evaluate

View File

@ -305,7 +305,7 @@ test "Prefix unary assignment operators are allowed in parenless calls.", ->
ok (func --val) is 5
test "#855: execution context for `func arr...` should be `null`", ->
contextTest = -> eq @, global
contextTest = -> eq @, if window? then window else global
array = []
contextTest array
contextTest.apply null, array

View File

@ -27,10 +27,9 @@
start = new Date
success = total = done = failed = 0
say = (msg, yay) ->
say = (msg) ->
div = document.createElement 'div'
div.appendChild document.createTextNode msg
div.style.color = if yay then 'green' else 'red'
stdout.appendChild div
msg
@ -72,16 +71,9 @@
return
ok no
CoffeeScript.run = (code, cb) ->
try Function(CoffeeScript.compile code, wrap: no)()
catch e then cb(); throw e
cb yes
run = (name) ->
CoffeeScript.load "#{name}.coffee", (yay) ->
say "#{ if yay then '\u2714' else '\u3000' } #{name}", yay
++failed unless yay
CoffeeScript.load "#{name}.coffee", ->
say '\u2714 ' + name
fin() if ++done is names.length
fin = ->
@ -92,12 +84,10 @@
say msg, yay
run name for name in names = [
'array_literals'
'arrays'
'assignment'
'boolean_literals'
'cake'
'booleans'
'classes'
'command'
'comments'
'compilation'
'comprehensions'
@ -105,22 +95,22 @@
'exception_handling'
'formatting'
'function_invocation'
'function_literals'
'functions'
'helpers'
'importing'
'interpolation'
'javascript_literals'
'number_literals'
'object_literals'
'numbers'
'objects'
'operators'
'option_parser'
'range_literals'
'regular_expression_literals'
'ranges'
'regexps'
'repl'
'scope'
'slicing_and_splicing'
'soaks'
'string_literals'
'strings'
]
</script>