FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
NodeJsServer/source/node_modules/generate-function/test.js at master · zsboss/NodeJsServer · GitHub
zsboss
NodeJsServer
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
NodeJsServer
/
source
/
node_modules
/
generate-function
/
test.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (27 loc) · 796 Bytes
Breadcrumbs
NodeJsServer
/
source
/
node_modules
/
generate-function
/
test.js
Copy path
File metadata and controls
33 lines (27 loc) · 796 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
(
)
}
)
Back
|
FazBrowse Home
|
New Git URL