Implement = operator

This commit is contained in:
2025-03-22 02:36:54 +01:00
parent 4694a5b9aa
commit d7f88a2f21
2 changed files with 40 additions and 1 deletions

View File

@@ -303,6 +303,40 @@ func TestLuaMathFunctions(t *testing.T) {
}
}
func TestDirectAssignment(t *testing.T) {
fileContents := `
<config>
<item>
<value>100</value>
</item>
</config>
`
expected := `
<config>
<item>
<value>0</value>
</item>
</config>
`
regex := regexp.MustCompile(`(?s)<value>(\d+)</value>`)
luaExpr := `=0`
luaScript := buildLuaScript(luaExpr)
t.Logf("Lua script: %s", luaScript) // Log the generated script for debugging
modifiedContent, err := process(fileContents, regex, luaScript)
if err != nil {
t.Fatalf("Error processing file: %v", err)
}
normalizedModified := normalizeWhitespace(modifiedContent)
normalizedExpected := normalizeWhitespace(expected)
if normalizedModified != normalizedExpected {
t.Fatalf("Expected modified content to be %q, but got %q", normalizedExpected, normalizedModified)
}
}
// Test with actual files
func TestProcessingSampleFiles(t *testing.T) {
// Read test files