Implement = operator
This commit is contained in:
34
main_test.go
34
main_test.go
@@ -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
|
||||
|
Reference in New Issue
Block a user