Browse Source

BUGFIX: Jump operations skipping an operation once maxJumps reached.

n1474335 8 years ago
parent
commit
70603be5ab
2 changed files with 45 additions and 2 deletions
  1. 0 2
      src/js/core/FlowControl.js
  2. 45 0
      test/tests/operations/FlowControl.js

+ 0 - 2
src/js/core/FlowControl.js

@@ -128,7 +128,6 @@ var FlowControl = {
             maxJumps = ings[1];
             maxJumps = ings[1];
 
 
         if (state.numJumps >= maxJumps) {
         if (state.numJumps >= maxJumps) {
-            state.progress++;
             return state;
             return state;
         }
         }
 
 
@@ -156,7 +155,6 @@ var FlowControl = {
             maxJumps = ings[2];
             maxJumps = ings[2];
 
 
         if (state.numJumps >= maxJumps) {
         if (state.numJumps >= maxJumps) {
-            state.progress++;
             return state;
             return state;
         }
         }
 
 

+ 45 - 0
test/tests/operations/FlowControl.js

@@ -64,4 +64,49 @@ TestRegister.addTests([
             {"op":"To Base64", "args":["A-Za-z0-9+/="]}
             {"op":"To Base64", "args":["A-Za-z0-9+/="]}
         ]
         ]
     },
     },
+    {
+        name: "Conditional Jump: Skips 0",
+        input: [
+            "match",
+            "should be changed 1",
+            "should be changed 2",
+        ].join("\n"),
+        expectedOutput: [
+            "match",
+            "should be changed 1 was changed",
+            "should be changed 2 was changed"
+        ].join("\n"),
+        recipeConfig: [
+            {
+                op: "Conditional Jump",
+                args: ["match", 0, 0],
+            },
+            {
+                op: "Find / Replace",
+                args: [
+                    {
+                        "option": "Regex",
+                        "string": "should be changed 1"
+                    },
+                    "should be changed 1 was changed",
+                    true,
+                    true,
+                    true,
+                ],
+            },
+            {
+                op: "Find / Replace",
+                args: [
+                    {
+                        "option": "Regex",
+                        "string": "should be changed 2"
+                    },
+                    "should be changed 2 was changed",
+                    true,
+                    true,
+                    true,
+                ],
+            },
+        ],
+    },
 ]);
 ]);