(t *testing.T)
| 1387 | } |
| 1388 | |
| 1389 | func TestStdlibCompat_BackReferences(t *testing.T) { |
| 1390 | // Note: Go regexp does not support backreferences, so these should |
| 1391 | // match behavior in treating \1 etc. as octal escapes or errors |
| 1392 | patterns := []struct { |
| 1393 | pattern string |
| 1394 | input string |
| 1395 | wantErr bool |
| 1396 | }{ |
| 1397 | // Valid patterns (no backreferences in Go regexp) |
| 1398 | {`(a)\1`, "aa", false}, // Go treats \1 as octal 1 (SOH character) |
| 1399 | } |
| 1400 | |
| 1401 | for _, tc := range patterns { |
| 1402 | t.Run(tc.pattern, func(t *testing.T) { |
| 1403 | stdRe, stdErr := regexp.Compile(tc.pattern) |
| 1404 | cgRe, cgErr := Compile(tc.pattern) |
| 1405 | |
| 1406 | // Both should have same compile behavior |
| 1407 | if (stdErr == nil) != (cgErr == nil) { |
| 1408 | t.Errorf("Compile error mismatch:\n stdlib: %v\n coregex: %v", |
| 1409 | stdErr, cgErr) |
| 1410 | return |
| 1411 | } |
| 1412 | |
| 1413 | if stdErr != nil { |
| 1414 | return // Both failed, consistent |
| 1415 | } |
| 1416 | |
| 1417 | // Compare behavior |
| 1418 | stdMatch := stdRe.MatchString(tc.input) |
| 1419 | cgMatch := cgRe.MatchString(tc.input) |
| 1420 | |
| 1421 | if stdMatch != cgMatch { |
| 1422 | t.Errorf("MatchString(%q, %q):\n stdlib: %v\n coregex: %v", |
| 1423 | tc.pattern, tc.input, stdMatch, cgMatch) |
| 1424 | } |
| 1425 | }) |
| 1426 | } |
| 1427 | } |
| 1428 | |
| 1429 | func TestStdlibCompat_PerlFlags(t *testing.T) { |
| 1430 | // Known differences: combined flags with case-insensitive matching |
nothing calls this directly
no test coverage detected