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