Please enable JavaScript to use RhodeCode Enterprise
Commit Description:
submission report
Commit Description:
submission report
var falafel = require ( '../' );
var test = require ( 'tape' );
test ( 'for loop' , function ( t ) {
t . plan ( 7 );
var src = '(function () {'
+ 'var sum = 0;'
+ 'for (var i = 0; i < 10; i++)'
+ 'sum += i;'
+ 'if (true)'
+ 'for (var i = 0; i < 10; i++)'
+ 'sum += i;'
+ 'return sum;'
+ '})()' ;
var output = falafel ( src , function ( node ) {
if ( node . type === 'ForStatement' ) {
t . equal ( node . update . source (), 'i++' );
t . equal ( node . update . type , "UpdateExpression" );
node . update . update ( 'i+=2' );
}
if ( node . type === 'UpdateExpression' ) {
t . equal ( node . source (), 'i++' );
}
});
var res = Function ( 'return ' + output )();
t . equal ( res , 2 + 4 + 6 + 8 + 2 + 4 + 6 + 8 );
});
Site-wide shortcuts
/
Use quick search box
g h
Goto home page
g g
Goto my private gists page
g G
Goto my public gists page
n r
New repository page
n g
New gist page
Repositories
g s
Goto summary page
g c
Goto changelog page
g f
Goto files page
g F
Goto files page with file search activated
g p
Goto pull requests page
g o
Goto repository settings
g O
Goto repository permissions settings