comments and tests

This commit is contained in:
Jeremy Ashkenas 2010-03-16 06:54:49 -04:00
parent 61dee1beba
commit e3021909c2
5 changed files with 17 additions and 16 deletions

View File

@ -70,8 +70,6 @@ task 'doc:underscore', 'rebuild the Underscore.coffee documentation page', ->
task 'test', 'run the CoffeeScript language test suite', ->
helpers.extend global, require 'assert'
require.paths.unshift './test'
test_count: 0
start_time: new Date()
[original_ok, original_throws]: [ok, throws]
@ -85,9 +83,10 @@ task 'test', 'run the CoffeeScript language test suite', ->
puts '\033[0;32mpassed ' + test_count + ' tests in ' + time + ' seconds\033[0m'
fs.readdir 'test', (err, files) ->
files.forEach (file) ->
fs.readFile 'test/' + file, (err, code) ->
source: path.join 'test', file
fs.readFile source, (err, code) ->
try
CoffeeScript.run code, {source: file}
CoffeeScript.run code, {source: source}
catch err
puts "Failed test: $file"
puts "Failed test: $source"
throw err

View File

@ -36,6 +36,7 @@ helpers.merge: merge: (options, overrides) ->
fresh
# Extend a source object with the properties of another object (shallow copy).
# We use this to simulate Node's deprecated `process.mixin`
helpers.extend: extend: (object, properties) ->
(object[key]: val) for key, val of properties

View File

@ -1,10 +1,9 @@
# The CoffeeScript language has a decent amount of optional syntax,
# implicit syntax, and shorthand syntax. These things can greatly complicate a
# grammar and bloat the resulting parse table. Instead of making the parser
# handle it all, we take a series of passes over the token stream,
# using this **Rewriter** to convert shorthand into the unambiguous long form,
# add implicit indentation and parentheses, balance incorrect nestings, and
# generally clean things up.
# The CoffeeScript language has a good deal of optional syntax, implicit syntax,
# and shorthand syntax. This can greatly complicate a grammar and bloat
# the resulting parse table. Instead of making the parser handle it all, we take
# a series of passes over the token stream, using this **Rewriter** to convert
# shorthand into the unambiguous long form, add implicit indentation and
# parentheses, balance incorrect nestings, and generally clean things up.
# Set up exported variables for both Node.js and the browser.
if process?
@ -56,11 +55,11 @@ exports.Rewriter: class Rewriter
return 1 unless token[0] is 'COMMENT'
after: @tokens[i + 2]
if after and after[0] is 'INDENT'
@tokens.splice(i + 2, 1)
@tokens.splice(i, 0, after)
@tokens.splice i + 2, 1
@tokens.splice i, 0, after
return 1
else if prev and prev[0] isnt 'TERMINATOR' and prev[0] isnt 'INDENT' and prev[0] isnt 'OUTDENT'
@tokens.splice(i, 0, ['TERMINATOR', "\n", prev[2]])
@tokens.splice i, 0, ['TERMINATOR', "\n", prev[2]]
return 2
else
return 1

View File

@ -1,2 +1,2 @@
# Check if it can import and execute a coffeescript-only module successfully.
ok require('test_module').func() is "from over there"
ok require('./test_module').func() is "from over there"

View File

@ -1,3 +1,5 @@
# This file is imported by `test_importing.coffee`
local: "from over there"
exports.func: -> local