PageRenderTime 33ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/test/importing.coffee

http://github.com/jashkenas/coffee-script
CoffeeScript | 34 lines | 25 code | 6 blank | 3 comment | 6 complexity | 588c1e93529458a7ca78616beeb2a42a MD5 | raw file
  1. # Importing
  2. # ---------
  3. unless window? or testingBrowser?
  4. test "coffeescript modules can be imported and executed", ->
  5. magicKey = __filename
  6. magicValue = 0xFFFF
  7. if global[magicKey]?
  8. if exports?
  9. local = magicValue
  10. exports.method = -> local
  11. else
  12. global[magicKey] = {}
  13. if require?.extensions?
  14. ok require(__filename).method() is magicValue
  15. delete global[magicKey]
  16. test "javascript modules can be imported", ->
  17. magicVal = 1
  18. for module in 'import.js import2 .import2 import.extension.js import.unknownextension .coffee .coffee.md'.split ' '
  19. ok require("./importing/#{module}").value?() is magicVal, module
  20. test "coffeescript modules can be imported", ->
  21. magicVal = 2
  22. for module in '.import.coffee import.coffee import.extension.coffee'.split ' '
  23. ok require("./importing/#{module}").value?() is magicVal, module
  24. test "literate coffeescript modules can be imported", ->
  25. magicVal = 3
  26. # Leading space intentional to check for index.coffee.md
  27. for module in ' .import.coffee.md import.coffee.md import.litcoffee import.extension.coffee.md'.split ' '
  28. ok require("./importing/#{module}").value?() is magicVal, module