Skip to content

Commit

Permalink
Add test for compiler errors on require()d files
Browse files Browse the repository at this point in the history
  • Loading branch information
epidemian committed Mar 21, 2013
1 parent 67fd84f commit c0d1f22
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions test/error_messages.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{prettyErrorMessage} = CoffeeScript.helpers

assertErrorFormat = (code, expectedErrorFormat) ->
throws (-> CoffeeScript.compile code), (err) ->
throws (-> CoffeeScript.run code), (err) ->
message = prettyErrorMessage err, 'test.coffee', code
eq expectedErrorFormat, message
yes
Expand Down Expand Up @@ -41,4 +41,23 @@ test "compiler error formatting", ->
test.coffee:1:14: error: parameter name "eval" is not allowed
evil = (foo, eval, bar) ->
^^^^
'''
'''

fs = require 'fs'

test "#2849: compilation error in a require()d file", ->
# Create a temporary file to require().
ok not fs.existsSync 'test/syntax-error.coffee'
fs.writeFileSync 'test/syntax-error.coffee', 'foo in bar or in baz'

try
assertErrorFormat '''
require './test/syntax-error'
''',
"""
#{__dirname}/syntax-error.coffee:1:15: error: unexpected RELATION
foo in bar or in baz
^^
"""
finally
fs.unlink 'test/syntax-error.coffee'

0 comments on commit c0d1f22

Please sign in to comment.