mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
# add dist
This commit is contained in:
33
ng2-components/ng2-alfresco-documentslist/dist/node_modules/generate-function/test.js
generated
vendored
Normal file
33
ng2-components/ng2-alfresco-documentslist/dist/node_modules/generate-function/test.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
var tape = require('tape')
|
||||
var genfun = require('./')
|
||||
|
||||
tape('generate add function', function(t) {
|
||||
var fn = genfun()
|
||||
('function add(n) {')
|
||||
('return n + %d', 42)
|
||||
('}')
|
||||
|
||||
t.same(fn.toString(), 'function add(n) {\n return n + 42\n}', 'code is indented')
|
||||
t.same(fn.toFunction()(10), 52, 'function works')
|
||||
t.end()
|
||||
})
|
||||
|
||||
tape('generate function + closed variables', function(t) {
|
||||
var fn = genfun()
|
||||
('function add(n) {')
|
||||
('return n + %d + number', 42)
|
||||
('}')
|
||||
|
||||
var notGood = fn.toFunction()
|
||||
var good = fn.toFunction({number:10})
|
||||
|
||||
try {
|
||||
notGood(10)
|
||||
t.ok(false, 'function should not work')
|
||||
} catch (err) {
|
||||
t.same(err.message, 'number is not defined', 'throws reference error')
|
||||
}
|
||||
|
||||
t.same(good(11), 63, 'function with closed var works')
|
||||
t.end()
|
||||
})
|
Reference in New Issue
Block a user