Skip to content

Commit

Permalink
wip2
Browse files Browse the repository at this point in the history
  • Loading branch information
wkhere committed Apr 28, 2024
1 parent 9489225 commit 3920849
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 17 deletions.
37 changes: 28 additions & 9 deletions apigen_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 36 additions & 8 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,45 @@ def q(s): return s.encode('unicode-escape').decode()
for _, tc := range tab {
tc := tc
t.Run(tc.name, func(t *testing.T) {
b := new(bytes.Buffer)
Interpret([]byte(tc.input), OptOutput(b), OptDisasm(tc.disasm))
s := b.String()
s = strings.TrimRight(s, "\n")
if s != tc.output {
t.Errorf("mismatch:\nhave: %s\nwant: %s", s, tc.output)
out := new(bytes.Buffer)
log := new(bytes.Buffer)
_, err := Interpret(
[]byte(tc.input),
OptDisasm(tc.disasm),
OptOutput(out), OptLogger(log),
)
switch {
case err != nil && !tc.errAllowed:
t.Errorf("unexpected error: %s", relevantError(err, log.String()))
case err != nil && tc.errAllowed:
rerr := relevantError(err, log.String())
if !strings.Contains(rerr, tc.errMatch) {
t.Errorf("error mismatch\nhave: %s\nwant matching: %s",
rerr, tc.errMatch,
)
}
case err == nil:
s := strings.TrimRight(out.String(), "\n")
if s != tc.output {
t.Errorf("mismatch:\nhave: %s\nwant: %s", s, tc.output)
}
}
})
}
}"""
}
func relevantError(err error, logged string) string {
if s := err.Error(); strings.HasPrefix(s, "combined errors") {
return logged
} else {
return s
}
}
"""


def generate():
Expand Down

0 comments on commit 3920849

Please sign in to comment.