New tests for module importing
This commit is contained in:
parent
e4407dd73c
commit
e7d01b903f
|
@ -16,3 +16,19 @@ unless window? or testingBrowser?
|
|||
if require?.extensions?
|
||||
ok require(__filename).method() is magicValue
|
||||
delete global[magicKey]
|
||||
|
||||
test "javascript modules can be imported", ->
|
||||
magicVal = 1
|
||||
for module in 'test.js test2 .test2 test.extension.js test.unknownextension .coffee .coffee.md'.split ' '
|
||||
ok require("./importing/#{module}").value?() is magicVal, module
|
||||
|
||||
test "coffeescript modules can be imported", ->
|
||||
magicVal = 2
|
||||
for module in '.test.coffee test.coffee test.extension.coffee'.split ' '
|
||||
ok require("./importing/#{module}").value?() is magicVal, module
|
||||
|
||||
test "literate coffeescript modules can be imported", ->
|
||||
magicVal = 3
|
||||
# Leading space intentional to check for index.coffee.md
|
||||
for module in ' .test.coffee.md test.coffee.md test.litcoffee test.extension.coffee.md'.split ' '
|
||||
ok require("./importing/#{module}").value?() is magicVal, module
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
Importing
|
||||
---------
|
||||
|
||||
unless window? or testingBrowser?
|
||||
test "literate coffeescript modules can be imported and executed", ->
|
||||
|
||||
magicKey = __filename
|
||||
magicValue = 0xFFFF
|
||||
|
||||
if global[magicKey]?
|
||||
if exports?
|
||||
local = magicValue
|
||||
exports.method = -> local
|
||||
else
|
||||
global[magicKey] = {}
|
||||
if require?.extensions?
|
||||
ok require(__filename).method() is magicValue
|
||||
delete global[magicKey]
|
|
@ -0,0 +1,2 @@
|
|||
// Required by ../importing.coffee
|
||||
module.exports = {value: function(){return 1;}};
|
|
@ -0,0 +1,2 @@
|
|||
// Required by ../importing.coffee
|
||||
module.exports = {value: function(){return 1;}};
|
|
@ -0,0 +1,2 @@
|
|||
# Required by ../importing.coffee
|
||||
module.exports = {value: -> 2}
|
|
@ -0,0 +1,3 @@
|
|||
Required by ../importing.coffee
|
||||
|
||||
module.exports = {value: -> 3}
|
|
@ -0,0 +1,2 @@
|
|||
// Required by ../importing.coffee
|
||||
module.exports = {value: function(){return 1;}};
|
|
@ -0,0 +1,3 @@
|
|||
Required by ../importing.coffee
|
||||
|
||||
module.exports = {value: -> 3}
|
|
@ -0,0 +1,3 @@
|
|||
Required by ../importing.coffee
|
||||
|
||||
module.exports = {value: -> 3}
|
|
@ -0,0 +1,2 @@
|
|||
# Required by ../importing.coffee
|
||||
module.exports = {value: -> 2}
|
|
@ -0,0 +1,3 @@
|
|||
Required by ../importing.coffee
|
||||
|
||||
module.exports = {value: -> 3}
|
|
@ -0,0 +1,2 @@
|
|||
// Required by ../importing.coffee
|
||||
module.exports = {value: function(){return 1;}};
|
|
@ -0,0 +1,2 @@
|
|||
// Required by ../importing.coffee
|
||||
module.exports = {value: function(){return 1;}};
|
|
@ -0,0 +1,2 @@
|
|||
// Required by ../importing.coffee
|
||||
module.exports = {value: function(){return 1;}};
|
|
@ -0,0 +1,2 @@
|
|||
// Required by ../importing.coffee
|
||||
module.exports = {value: function(){return 1;}};
|
|
@ -0,0 +1 @@
|
|||
test.js
|
Loading…
Reference in New Issue