Add test:browser task for running the test suite against the merged browser script.
This commit is contained in:
parent
de0b93381c
commit
f360fba47f
14
Cakefile
14
Cakefile
|
@ -97,7 +97,7 @@ task 'loc', 'count the lines of source code in the CoffeeScript compiler', ->
|
|||
print stdout
|
||||
|
||||
|
||||
task 'test', 'run the CoffeeScript language test suite', ->
|
||||
runTests = (CoffeeScript) ->
|
||||
startTime = Date.now()
|
||||
passedTests = failedTests = 0
|
||||
for all name, func of require 'assert'
|
||||
|
@ -121,3 +121,15 @@ task 'test', 'run the CoffeeScript language test suite', ->
|
|||
catch err
|
||||
failedTests += 1
|
||||
log "failed #{fileName}", red, '\n' + err.stack.toString()
|
||||
|
||||
|
||||
task 'test', 'run the CoffeeScript language test suite', ->
|
||||
runTests CoffeeScript
|
||||
|
||||
|
||||
task 'test:browser', 'run the test suite against the merged browser script', ->
|
||||
source = fs.readFileSync 'extras/coffee-script.js', 'utf-8'
|
||||
window = addEventListener: ->
|
||||
window.window = window
|
||||
(-> eval source).call window
|
||||
runTests window.CoffeeScript
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -35,8 +35,8 @@
|
|||
return null;
|
||||
};
|
||||
if (window.addEventListener) {
|
||||
addEventListener('DOMContentLoaded', processScripts, false);
|
||||
window.addEventListener('DOMContentLoaded', processScripts, false);
|
||||
} else {
|
||||
attachEvent('onload', processScripts);
|
||||
window.attachEvent('onload', processScripts);
|
||||
}
|
||||
}).call(this);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
});
|
||||
}
|
||||
exports.VERSION = '0.9.4';
|
||||
exports.helpers = require('./helpers');
|
||||
exports.compile = (compile = function(code, options) {
|
||||
options || (options = {});
|
||||
try {
|
||||
|
|
|
@ -34,6 +34,6 @@ processScripts = ->
|
|||
setTimeout -> CoffeeScript.run script.innerHTML
|
||||
null
|
||||
if window.addEventListener
|
||||
addEventListener 'DOMContentLoaded', processScripts, false
|
||||
window.addEventListener 'DOMContentLoaded', processScripts, false
|
||||
else
|
||||
attachEvent 'onload', processScripts
|
||||
window.attachEvent 'onload', processScripts
|
||||
|
|
|
@ -22,6 +22,9 @@ else if require.registerExtension
|
|||
# The current CoffeeScript version number.
|
||||
exports.VERSION = '0.9.4'
|
||||
|
||||
# Expose helpers for testing.
|
||||
exports.helpers = require './helpers'
|
||||
|
||||
# Compile a string of CoffeeScript code to JavaScript, using the Coffee/Jison
|
||||
# compiler.
|
||||
exports.compile = compile = (code, options) ->
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
# Ensure that carriage returns don't break compilation on Windows.
|
||||
CoffeeScript = require('./../lib/coffee-script')
|
||||
Lexer = require('./../lib/lexer')
|
||||
|
||||
js = CoffeeScript.compile("one\r\ntwo", {wrap: off})
|
||||
|
||||
ok js is "one;\ntwo;"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{indexOf, include, starts, ends, compact, count, merge, extend, flatten, del, last} = require '../lib/helpers'
|
||||
{indexOf, include, starts, ends, compact, count, merge, extend, flatten, del, last} = CoffeeScript.helpers
|
||||
|
||||
array = [0..4]
|
||||
string = array.join ''
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# Check if we can import and execute a CoffeeScript-only module successfully.
|
||||
ok require('./test_module').func() is "from over there"
|
||||
if require?.extensions? or require?.registerExtension?
|
||||
ok require('./test_module').func() is "from over there"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# This file is imported by `testImporting.coffee`
|
||||
|
||||
local = "from over there"
|
||||
|
||||
exports.func = -> local
|
||||
if exports?
|
||||
local = "from over there"
|
||||
exports.func = -> local
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Ensure that the OptionParser handles arguments correctly.
|
||||
|
||||
return unless require?
|
||||
{OptionParser} = require './../lib/optparse'
|
||||
|
||||
opt = new OptionParser [
|
||||
|
|
Loading…
Reference in New Issue