diff --git a/Cakefile b/Cakefile index 67f95d87..058f83a6 100644 --- a/Cakefile +++ b/Cakefile @@ -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 diff --git a/src/helpers.coffee b/src/helpers.coffee index 27896036..2e83e574 100644 --- a/src/helpers.coffee +++ b/src/helpers.coffee @@ -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 diff --git a/src/rewriter.coffee b/src/rewriter.coffee index a542f72d..f6863e84 100644 --- a/src/rewriter.coffee +++ b/src/rewriter.coffee @@ -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 diff --git a/test/test_importing.coffee b/test/test_importing.coffee index 1b61ce8b..c7f3391e 100644 --- a/test/test_importing.coffee +++ b/test/test_importing.coffee @@ -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" \ No newline at end of file +ok require('./test_module').func() is "from over there" \ No newline at end of file diff --git a/test/test_module.coffee b/test/test_module.coffee index 9937ac8e..e7769847 100644 --- a/test/test_module.coffee +++ b/test/test_module.coffee @@ -1,3 +1,5 @@ +# This file is imported by `test_importing.coffee` + local: "from over there" exports.func: -> local \ No newline at end of file