Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

failing test on for loops

  • Loading branch information...
commit cf1fcded15519e7214ce7911d6b6b7847d4c7f43 1 parent d1a274f
@substack authored
Showing with 25 additions and 0 deletions.
  1. +25 −0 test/for.js
View
25 test/for.js
@@ -0,0 +1,25 @@
+var falafel = require('../');
+var test = require('tap').test;
+var vm = require('vm');
+
+test('for loop', function (t) {
+ t.plan(2);
+
+ var src = '(' + function () {
+ var sum = 0;
+ 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++');
+ node.update.update('i+=2');
+ }
+ });
+
+ var res = vm.runInNewContext(output);
+ t.equal(res, 2 + 4 + 6 + 8);
+});
Please sign in to comment.
Something went wrong with that request. Please try again.