From d2346164061e6c20a358a277f091bcac65353cd9 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Fri, 22 Aug 2025 09:53:00 +0200 Subject: [PATCH] Add broken test --- processor/surgical_json_test.go | 226 ++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) diff --git a/processor/surgical_json_test.go b/processor/surgical_json_test.go index a3732f0..fdb459b 100644 --- a/processor/surgical_json_test.go +++ b/processor/surgical_json_test.go @@ -597,3 +597,229 @@ func TestRetardedJSONEditing(t *testing.T) { t.Errorf("Expected:\n%s\nGot:\n%s", expected, result) } } + + +func TestRetardedJSONEditing2(t *testing.T) { + original := ` + { + "Rows": [ + { + "Name": "Deep_Mining_Drill_Biofuel", + "Meshable": { + "RowName": "Mesh_Deep_Mining_Drill_Biofuel" + }, + "Itemable": { + "RowName": "Item_Deep_Mining_Drill_Biofuel" + }, + "Interactable": { + "RowName": "Deployable" + }, + "Focusable": { + "RowName": "Focusable_1H" + }, + "Highlightable": { + "RowName": "Generic" + }, + "Actionable": { + "RowName": "Deployable" + }, + "Usable": { + "RowName": "Place" + }, + "Deployable": { + "RowName": "Deep_Mining_Drill_Biofuel" + }, + "Durable": { + "RowName": "Deployable_750" + }, + "Inventory": { + "RowName": "Deep_Mining_Drill_Biofuel" + }, + "Decayable": { + "RowName": "Decay_MetaItem" + }, + "Generator": { + "RowName": "Deep_Mining_Biofuel_Drill" + }, + "Resource": { + "RowName": "Simple_Internal_Flow_Only" + }, + "Manual_Tags": { + "GameplayTags": [ + { + "TagName": "Item.Machine" + } + ] + }, + "Generated_Tags": { + "GameplayTags": [ + { + "TagName": "Item.Machine" + }, + { + "TagName": "Traits.Meshable" + }, + { + "TagName": "Traits.Itemable" + }, + { + "TagName": "Traits.Interactable" + }, + { + "TagName": "Traits.Highlightable" + }, + { + "TagName": "Traits.Actionable" + }, + { + "TagName": "Traits.Usable" + }, + { + "TagName": "Traits.Deployable" + }, + { + "TagName": "Traits.Durable" + }, + { + "TagName": "Traits.Inventory" + } + ], + "ParentTags": [] + } + } + ] + } + ` + + expected := ` + { + "Rows": [ + { + "Name": "Deep_Mining_Drill_Biofuel", + "Meshable": { + "RowName": "Mesh_Deep_Mining_Drill_Biofuel" + }, + "Itemable": { + "RowName": "Item_Deep_Mining_Drill_Biofuel" + }, + "Interactable": { + "RowName": "Deployable" + }, + "Focusable": { + "RowName": "Focusable_1H" + }, + "Highlightable": { + "RowName": "Generic" + }, + "Actionable": { + "RowName": "Deployable" + }, + "Usable": { + "RowName": "Place" + }, + "Deployable": { + "RowName": "Deep_Mining_Drill_Biofuel" + }, + "Durable": { + "RowName": "Deployable_750" + }, + "Inventory": { + "RowName": "Deep_Mining_Drill_Biofuel" + }, + "Decayable": { + "RowName": "Decay_MetaItem" + }, + "Generator": { + "RowName": "Deep_Mining_Biofuel_Drill" + }, + "Resource": { + "RowName": "Simple_Internal_Flow_Only" + }, + "Manual_Tags": { + "GameplayTags": [ + { + "TagName": "Item.Machine" + } + ] + }, + "Generated_Tags": { + "GameplayTags": [ + { + "TagName": "Item.Machine" + }, + { + "TagName": "Traits.Meshable" + }, + { + "TagName": "Traits.Itemable" + }, + { + "TagName": "Traits.Interactable" + }, + { + "TagName": "Traits.Highlightable" + }, + { + "TagName": "Traits.Actionable" + }, + { + "TagName": "Traits.Usable" + }, + { + "TagName": "Traits.Deployable" + }, + { + "TagName": "Traits.Durable" + }, + { + "TagName": "Traits.Inventory" + } + ], + "ParentTags": [] + } + ,"AdditionalStats": { + "(Value=\"BaseDeepMiningDrillSpeed_+%\")": 4000 + } + } + ] + } + ` + + command := utils.ModifyCommand{ + Name: "test", + Lua: ` + for i, row in ipairs(data.Rows) do + -- Special case: Deep_Mining_Drill_Biofuel + if string.find(row.Name, "Deep_Mining_Drill_Biofuel") then + print("[DEBUG] Special case: Deep_Mining_Drill_Biofuel") + if not row.AdditionalStats then + print("[DEBUG] Creating AdditionalStats table for Deep_Mining_Drill_Biofuel") + row.AdditionalStats = {} + end + print("[DEBUG] Setting BaseDeepMiningDrillSpeed_+% to 4000") + row.AdditionalStats["(Value=\\\"BaseDeepMiningDrillSpeed_+%\\\")"] = 4000 + end + end +`, + } + + commands, err := ProcessJSON(original, command, "test.json") + if err != nil { + t.Fatalf("ProcessJSON failed: %v", err) + } + + if len(commands) == 0 { + t.Fatal("Expected at least one command") + } + + // Apply the commands + result := original + for _, cmd := range commands { + result = result[:cmd.From] + cmd.With + result[cmd.To:] + } + + // Check that the weight was changed + if result != expected { + t.Errorf("Expected:\n%s\nGot:\n%s", expected, result) + } +} \ No newline at end of file