浏览代码

Fork no longer appends its merge delimiter to the end of the output. Closes #692

n1474335 5 年之前
父节点
当前提交
3e3322e1f0
共有 3 个文件被更改,包括 6 次插入6 次删除
  1. 4 4
      src/core/operations/Fork.mjs
  2. 1 1
      tests/operations/tests/Comment.mjs
  3. 1 1
      tests/operations/tests/Fork.mjs

+ 4 - 4
src/core/operations/Fork.mjs

@@ -76,8 +76,8 @@ class Fork extends Operation {
         }
 
         const recipe = new Recipe();
-        let output = "",
-            progress = 0;
+        const outputs = [];
+        let progress = 0;
 
         state.forkOffset += state.progress + 1;
 
@@ -104,10 +104,10 @@ class Fork extends Operation {
                 }
                 progress = err.progress + 1;
             }
-            output += await dish.get(outputType) + mergeDelim;
+            outputs.push(await dish.get(outputType));
         }
 
-        state.dish.set(output, outputType);
+        state.dish.set(outputs.join(mergeDelim), outputType);
         state.progress += progress;
         return state;
     }

+ 1 - 1
tests/operations/tests/Comment.mjs

@@ -42,7 +42,7 @@ TestRegister.addTests([
     {
         name: "Fork, Comment, Base64",
         input: "cat\nsat\nmat",
-        expectedOutput: "Y2F0\nc2F0\nbWF0\n",
+        expectedOutput: "Y2F0\nc2F0\nbWF0",
         recipeConfig: [
             {
                 "op": "Fork",

+ 1 - 1
tests/operations/tests/Fork.mjs

@@ -57,7 +57,7 @@ TestRegister.addTests([
     {
         name: "Fork, Conditional Jump, Encodings",
         input: "Some data with a 1 in it\nSome data with a 2 in it",
-        expectedOutput: "U29tZSBkYXRhIHdpdGggYSAxIGluIGl0\n53 6f 6d 65 20 64 61 74 61 20 77 69 74 68 20 61 20 32 20 69 6e 20 69 74\n",
+        expectedOutput: "U29tZSBkYXRhIHdpdGggYSAxIGluIGl0\n53 6f 6d 65 20 64 61 74 61 20 77 69 74 68 20 61 20 32 20 69 6e 20 69 74",
         recipeConfig: [
             {"op": "Fork", "args": ["\\n", "\\n", false]},
             {"op": "Conditional Jump", "args": ["1", false, "skipReturn", "10"]},