diff --git a/Cakefile b/Cakefile index 1bd9240e..bf12f6aa 100644 --- a/Cakefile +++ b/Cakefile @@ -74,6 +74,7 @@ task 'test', 'run the CoffeeScript language test suite', -> process.mixin { ok: (args...) -> test_count += 1; original_ok(args...) throws: (args...) -> test_count += 1; original_throws(args...) + CoffeeScript: CoffeeScript } process.addListener 'exit', -> time: ((new Date() - start_time) / 1000).toFixed(2) diff --git a/lib/lexer.js b/lib/lexer.js index 9a6dc514..80d761ae 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -33,7 +33,8 @@ Lexer.prototype.tokenize = function tokenize(code, options) { var o; o = options || {}; - this.code = code || ''; + code = code.replace(/\r/g, ''); + this.code = code; // The remainder of the source code. this.i = 0; // Current character position we're parsing. diff --git a/src/lexer.coffee b/src/lexer.coffee index fd532159..75350b7d 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -35,8 +35,9 @@ exports.Lexer: class Lexer # Before returning the token stream, run it through the [Rewriter](rewriter.html) # unless explicitly asked not to. tokenize: (code, options) -> + code : code.replace(/\r/g, '') o : options or {} - @code : code or '' # The remainder of the source code. + @code : code # The remainder of the source code. @i : 0 # Current character position we're parsing. @line : o.line or 0 # The current line. @indent : 0 # The current indentation level. diff --git a/test/test_compilation.coffee b/test/test_compilation.coffee new file mode 100644 index 00000000..067ba974 --- /dev/null +++ b/test/test_compilation.coffee @@ -0,0 +1,3 @@ +js: CoffeeScript.compile("one\r\ntwo", {no_wrap: on}) + +ok js is "one;\ntwo;" \ No newline at end of file