Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
4e0b7878
...
4e0b7878dfc62261c1f01255919467f17e82c45d
authored
2012-05-31 21:58:25 +0200
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixes #129 - Can't put // comments in evaluate() function
1 parent
ef3540a0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletions
modules/injector.js
tests/suites/injector.js
modules/injector.js
View file @
4e0b787
...
...
@@ -67,7 +67,9 @@ var FunctionArgsInjector = function FunctionArgsInjector(fn) {
throw
new
CasperError
(
"Unable to process function "
+
this
.
fn
.
toString
());
}
var
inject
=
this
.
getArgsInjectionString
(
fnObj
.
args
,
values
);
return
'function '
+
(
fnObj
.
name
||
''
)
+
'(){'
+
inject
+
fnObj
.
body
+
'}'
;
var
newFn
=
new
Function
([
inject
,
fnObj
.
body
].
join
(
'\n'
));
newFn
.
name
=
fnObj
.
name
||
''
;
return
newFn
;
};
this
.
getArgsInjectionString
=
function
getArgsInjectionString
(
args
,
values
)
{
...
...
tests/suites/injector.js
View file @
4e0b787
...
...
@@ -19,6 +19,11 @@ function Plip() { return 'plop'; }
function
foo_bar
(
boz
)
{}
var
gni
=
function
(
$bubu_bibi
,
__popo__
)
{};
var
gno
=
function
(
arg1
,
/*plop*/
arg2
)
{
};
function
issue129
(
term
)
{
// see issue #129
return
term
;
// see issue #129
}
t
.
assertEquals
(
injector
.
extract
(
Plop
),
{
name
:
'Plop'
,
args
:
[
'foo'
,
'bar'
],
...
...
@@ -52,4 +57,8 @@ eval('processed = ' + injector.process({ a: 1, b: 2 }));
t
.
assertType
(
processed
,
"function"
,
'FunctionArgsInjector.process() processed a function'
);
t
.
assertEquals
(
processed
(),
3
,
'FunctionArgsInjector.process() processed the function correctly'
);
// Issue #129
var
fnIssue129
=
createInjector
(
issue129
).
process
({
term
:
'fixed'
});
t
.
assertEquals
(
fnIssue129
(
'fixed'
),
'fixed'
,
'FunctionArgsInjector.process() has issue #129 fixed'
);
t
.
done
();
...
...
Please
register
or
sign in
to post a comment