Minor fuckings
This commit is contained in:
2
main.go
2
main.go
@@ -106,7 +106,7 @@ func main() {
|
|||||||
patternModified := false
|
patternModified := false
|
||||||
|
|
||||||
if strings.Contains(regexPattern, "!num") {
|
if strings.Contains(regexPattern, "!num") {
|
||||||
regexPattern = strings.ReplaceAll(regexPattern, "!num", "(\\d*\\.?\\d+)")
|
regexPattern = strings.ReplaceAll(regexPattern, "!num", "(-?\\d*\\.?\\d+)")
|
||||||
patternModified = true
|
patternModified = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
36
main_test.go
36
main_test.go
@@ -35,7 +35,7 @@ func TestSimpleValueMultiplication(t *testing.T) {
|
|||||||
luaExpr := `*1.5`
|
luaExpr := `*1.5`
|
||||||
luaScript := buildLuaScript(luaExpr)
|
luaScript := buildLuaScript(luaExpr)
|
||||||
|
|
||||||
modifiedContent, err := process(fileContents, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContents, regex, luaScript, "test.xml", luaExpr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing file: %v", err)
|
t.Fatalf("Error processing file: %v", err)
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ func TestShorthandNotation(t *testing.T) {
|
|||||||
luaExpr := `v1 * 1.5` // Use direct assignment syntax
|
luaExpr := `v1 * 1.5` // Use direct assignment syntax
|
||||||
luaScript := buildLuaScript(luaExpr)
|
luaScript := buildLuaScript(luaExpr)
|
||||||
|
|
||||||
modifiedContent, err := process(fileContents, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContents, regex, luaScript, "test.xml", luaExpr )
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing file: %v", err)
|
t.Fatalf("Error processing file: %v", err)
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ func TestArrayNotation(t *testing.T) {
|
|||||||
luaExpr := `v1 = v1 * 1.5` // Use direct assignment syntax
|
luaExpr := `v1 = v1 * 1.5` // Use direct assignment syntax
|
||||||
luaScript := buildLuaScript(luaExpr)
|
luaScript := buildLuaScript(luaExpr)
|
||||||
|
|
||||||
modifiedContent, err := process(fileContents, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContents, regex, luaScript, "test.xml", luaExpr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing file: %v", err)
|
t.Fatalf("Error processing file: %v", err)
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ func TestMultipleMatches(t *testing.T) {
|
|||||||
luaExpr := `*1.5`
|
luaExpr := `*1.5`
|
||||||
luaScript := buildLuaScript(luaExpr)
|
luaScript := buildLuaScript(luaExpr)
|
||||||
|
|
||||||
modifiedContent, err := process(fileContents, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContents, regex, luaScript, "test.xml", luaExpr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing file: %v", err)
|
t.Fatalf("Error processing file: %v", err)
|
||||||
}
|
}
|
||||||
@@ -182,7 +182,7 @@ func TestMultipleCaptureGroups(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Logf("Matches: %v", matches)
|
t.Logf("Matches: %v", matches)
|
||||||
|
|
||||||
modifiedContent, err := process(fileContents, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContents, regex, luaScript, "test.xml", luaExpr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing file: %v", err)
|
t.Fatalf("Error processing file: %v", err)
|
||||||
}
|
}
|
||||||
@@ -225,7 +225,7 @@ func TestModifyingMultipleValues(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Logf("Matches: %v", matches)
|
t.Logf("Matches: %v", matches)
|
||||||
|
|
||||||
modifiedContent, err := process(fileContents, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContents, regex, luaScript, "test.xml", luaExpr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing file: %v", err)
|
t.Fatalf("Error processing file: %v", err)
|
||||||
}
|
}
|
||||||
@@ -259,7 +259,7 @@ func TestDecimalValues(t *testing.T) {
|
|||||||
luaExpr := `v1 = v1 * v2` // Use direct assignment syntax
|
luaExpr := `v1 = v1 * v2` // Use direct assignment syntax
|
||||||
luaScript := buildLuaScript(luaExpr)
|
luaScript := buildLuaScript(luaExpr)
|
||||||
|
|
||||||
modifiedContent, err := process(fileContents, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContents, regex, luaScript, "test.xml", luaExpr )
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing file: %v", err)
|
t.Fatalf("Error processing file: %v", err)
|
||||||
}
|
}
|
||||||
@@ -291,7 +291,7 @@ func TestLuaMathFunctions(t *testing.T) {
|
|||||||
luaExpr := `v1 = math.sqrt(v1)` // Use direct assignment syntax
|
luaExpr := `v1 = math.sqrt(v1)` // Use direct assignment syntax
|
||||||
luaScript := buildLuaScript(luaExpr)
|
luaScript := buildLuaScript(luaExpr)
|
||||||
|
|
||||||
modifiedContent, err := process(fileContents, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContents, regex, luaScript, "test.xml", luaExpr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing file: %v", err)
|
t.Fatalf("Error processing file: %v", err)
|
||||||
}
|
}
|
||||||
@@ -325,7 +325,7 @@ func TestDirectAssignment(t *testing.T) {
|
|||||||
|
|
||||||
t.Logf("Lua script: %s", luaScript) // Log the generated script for debugging
|
t.Logf("Lua script: %s", luaScript) // Log the generated script for debugging
|
||||||
|
|
||||||
modifiedContent, err := process(fileContents, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContents, regex, luaScript, "test.xml", luaExpr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing file: %v", err)
|
t.Fatalf("Error processing file: %v", err)
|
||||||
}
|
}
|
||||||
@@ -415,7 +415,7 @@ func TestProcessingSampleFiles(t *testing.T) {
|
|||||||
t.Logf("Lua expression: %s", tc.luaExpr)
|
t.Logf("Lua expression: %s", tc.luaExpr)
|
||||||
|
|
||||||
// Process the content
|
// Process the content
|
||||||
modifiedContent, err := process(tc.fileContent, regex, luaScript)
|
modifiedContent, _, _, err := process(tc.fileContent, regex, luaScript, "test.xml", tc.luaExpr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing file: %v", err)
|
t.Fatalf("Error processing file: %v", err)
|
||||||
}
|
}
|
||||||
@@ -465,7 +465,7 @@ func TestFileOperations(t *testing.T) {
|
|||||||
t.Logf("Lua expression: %s", luaExpr)
|
t.Logf("Lua expression: %s", luaExpr)
|
||||||
|
|
||||||
// Process the content
|
// Process the content
|
||||||
modifiedContent, err := process(fileContent, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContent, regex, luaScript, "test.xml", luaExpr )
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing file: %v", err)
|
t.Fatalf("Error processing file: %v", err)
|
||||||
}
|
}
|
||||||
@@ -502,7 +502,7 @@ func TestFileOperations(t *testing.T) {
|
|||||||
t.Logf("Lua expression: %s", luaExpr)
|
t.Logf("Lua expression: %s", luaExpr)
|
||||||
|
|
||||||
// Process the content
|
// Process the content
|
||||||
modifiedContent, err := process(fileContent, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContent, regex, luaScript, "test.xml", luaExpr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing file: %v", err)
|
t.Fatalf("Error processing file: %v", err)
|
||||||
}
|
}
|
||||||
@@ -537,7 +537,7 @@ func TestFileOperations(t *testing.T) {
|
|||||||
t.Logf("Lua expression: %s", luaExpr)
|
t.Logf("Lua expression: %s", luaExpr)
|
||||||
|
|
||||||
// Process the content
|
// Process the content
|
||||||
modifiedContent, err := process(fileContent, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContent, regex, luaScript, "test.xml", luaExpr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing file: %v", err)
|
t.Fatalf("Error processing file: %v", err)
|
||||||
}
|
}
|
||||||
@@ -574,7 +574,7 @@ func TestHigherVariableIndices(t *testing.T) {
|
|||||||
|
|
||||||
// Expected: 10 + 20 * 30 / 40 - 50 = 10 + 15 - 50 = -25
|
// Expected: 10 + 20 * 30 / 40 - 50 = 10 + 15 - 50 = -25
|
||||||
|
|
||||||
modifiedContent, err := process(fileContents, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContents, regex, luaScript, "test.xml", luaExpr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing with v3-v5: %v", err)
|
t.Fatalf("Error processing with v3-v5: %v", err)
|
||||||
}
|
}
|
||||||
@@ -594,7 +594,7 @@ func TestHigherVariableIndices(t *testing.T) {
|
|||||||
|
|
||||||
// Expected: 10 * 110 = 1100
|
// Expected: 10 * 110 = 1100
|
||||||
|
|
||||||
modifiedContent, err := process(fileContents, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContents, regex, luaScript, "test.xml", luaExpr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing with v11: %v", err)
|
t.Fatalf("Error processing with v11: %v", err)
|
||||||
}
|
}
|
||||||
@@ -613,7 +613,7 @@ func TestHigherVariableIndices(t *testing.T) {
|
|||||||
luaScript := buildLuaScript(luaExpr)
|
luaScript := buildLuaScript(luaExpr)
|
||||||
|
|
||||||
// This should double the value
|
// This should double the value
|
||||||
modifiedContent, err := process(fileContents, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContents, regex, luaScript, "test.xml", luaExpr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing with v0: %v", err)
|
t.Fatalf("Error processing with v0: %v", err)
|
||||||
}
|
}
|
||||||
@@ -649,7 +649,7 @@ func TestMultiStatementExpression(t *testing.T) {
|
|||||||
|
|
||||||
t.Logf("Generated Lua script: %s", luaScript)
|
t.Logf("Generated Lua script: %s", luaScript)
|
||||||
|
|
||||||
modifiedContent, err := process(fileContents, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContents, regex, luaScript, "test.xml", luaExpr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing file: %v", err)
|
t.Fatalf("Error processing file: %v", err)
|
||||||
}
|
}
|
||||||
@@ -698,7 +698,7 @@ end
|
|||||||
|
|
||||||
t.Logf("Generated Lua script: %s", luaScript)
|
t.Logf("Generated Lua script: %s", luaScript)
|
||||||
|
|
||||||
modifiedContent, err := process(fileContents, regex, luaScript)
|
modifiedContent, _, _, err := process(fileContents, regex, luaScript, "test.xml", luaExpr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error processing file: %v", err)
|
t.Fatalf("Error processing file: %v", err)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user