MCPcopy Create free account
hub / github.com/decomp/decomp / TestRewrite

Function TestRewrite

cmd/go-post/main_test.go:75–120  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

73}
74
75func TestRewrite(t *testing.T) {
76 for _, tt := range testCases {
77 // Apply fix: should get tt.Out.
78 out, fixed, ok := parseFixPrint(t, tt.Fn, tt.Name, tt.In, true)
79 if !ok {
80 continue
81 }
82
83 // reformat to get printing right
84 out, _, ok = parseFixPrint(t, fnop, tt.Name, out, false)
85 if !ok {
86 continue
87 }
88
89 if out != tt.Out {
90 t.Errorf("%s: incorrect output.\n", tt.Name)
91 if !strings.HasPrefix(tt.Name, "testdata/") {
92 t.Errorf("--- have\n%s\n--- want\n%s", out, tt.Out)
93 }
94 tdiff(t, out, tt.Out)
95 continue
96 }
97
98 if changed := out != tt.In; changed != fixed {
99 t.Errorf("%s: changed=%v != fixed=%v", tt.Name, changed, fixed)
100 continue
101 }
102
103 // Should not change if run again.
104 out2, fixed2, ok := parseFixPrint(t, tt.Fn, tt.Name+" output", out, true)
105 if !ok {
106 continue
107 }
108
109 if fixed2 {
110 t.Errorf("%s: applied fixes during second round", tt.Name)
111 continue
112 }
113
114 if out2 != out {
115 t.Errorf("%s: changed output after second round of fixes.\n--- output after first round\n%s\n--- output after second round\n%s",
116 tt.Name, out, out2)
117 tdiff(t, out, out2)
118 }
119 }
120}
121
122func tdiff(t *testing.T, a, b string) {
123 data, err := diff([]byte(a), []byte(b))

Callers

nothing calls this directly

Calls 2

parseFixPrintFunction · 0.85
tdiffFunction · 0.85

Tested by

no test coverage detected