From 1b2c55d9904dad85762014f61c252dfc0bad1ad7 Mon Sep 17 00:00:00 2001 From: Arpad Ryszka Date: Sat, 6 Sep 2025 22:00:22 +0200 Subject: [PATCH] test output --- docreflect.gen.go | 49 ++++++++++++++++++------------------- wand_test.go => lib_test.go | 0 output_test.go | 32 ++++++++++++++++++------ 3 files changed, 49 insertions(+), 32 deletions(-) rename wand_test.go => lib_test.go (100%) diff --git a/docreflect.gen.go b/docreflect.gen.go index c003166..45379f1 100644 --- a/docreflect.gen.go +++ b/docreflect.gen.go @@ -2,31 +2,30 @@ Generated with https://code.squareroundforest.org/arpio/docreflect */ + package wand - import "code.squareroundforest.org/arpio/docreflect" - func init() { - docreflect.Register("code.squareroundforest.org/arpio/wand/tools", "") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.Docreflect", "\nfunc(out, packageName, gopaths)") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.Exec", "\nfunc(o, stdin, args)") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.ExecOptions", "") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.ExecOptions.CacheDir", "") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.ExecOptions.ClearCache", "") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.ExecOptions.Import", "") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.ExecOptions.InlineImport", "") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.ExecOptions.NoCache", "") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.Man", "\nfunc(out, commandDir)") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.Markdown", "\nfunc(out, o, commandDir)") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.MarkdownOptions", "") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.MarkdownOptions.Level", "") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.commandReader", "\nfunc(in)") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.execCommandDir", "\nfunc(out, commandDir, env)") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.execInternal", "\nfunc(command, args)") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.execTransparent", "\nfunc(command, args)") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.execWand", "\nfunc(o, args)") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.execc", "\nfunc(stdin, stdout, stderr, command, args, env)") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.hash", "\nfunc(expression, imports, inlineImports)") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.printGoFile", "\nfunc(fn, expression, imports, inlineImports)") - docreflect.Register("code.squareroundforest.org/arpio/wand/tools.readExec", "\nfunc(o, stdin)") -} +docreflect.Register("code.squareroundforest.org/arpio/wand/tools", "") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.Docreflect", "\nfunc(out, packageName, gopaths)") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.Exec", "\nfunc(o, stdin, args)") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.ExecOptions", "") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.ExecOptions.CacheDir", "") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.ExecOptions.ClearCache", "") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.ExecOptions.Import", "") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.ExecOptions.InlineImport", "") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.ExecOptions.NoCache", "") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.Man", "\nfunc(out, commandDir)") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.Markdown", "\nfunc(out, o, commandDir)") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.MarkdownOptions", "") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.MarkdownOptions.Level", "") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.commandReader", "\nfunc(in)") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.execCommandDir", "\nfunc(out, commandDir, env)") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.execInternal", "\nfunc(command, args)") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.execTransparent", "\nfunc(command, args)") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.execWand", "\nfunc(o, args)") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.execc", "\nfunc(stdin, stdout, stderr, command, args, env)") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.hash", "\nfunc(expression, imports, inlineImports)") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.printGoFile", "\nfunc(fn, expression, imports, inlineImports)") +docreflect.Register("code.squareroundforest.org/arpio/wand/tools.readExec", "\nfunc(o, stdin)") +} \ No newline at end of file diff --git a/wand_test.go b/lib_test.go similarity index 100% rename from wand_test.go rename to lib_test.go diff --git a/output_test.go b/output_test.go index c28d9f4..515127e 100644 --- a/output_test.go +++ b/output_test.go @@ -1,12 +1,30 @@ package wand -import "testing" +import ( + "testing" + "time" + "io" + "bytes" +) func TestOutput(t *testing.T) { - // nil - // simple - // stringer - // pointer - // complex - // reader + // multiple, mixed outputs + + f0 := func() any { return nil } + f1 := func() int { return 42 } + f2 := func() time.Duration { return 9 * time.Second } + f3 := func() *int { i := 42; return &i } + f4 := func() chan int { return make(chan int) } + f5 := func() io.Reader { return bytes.NewBufferString("foo") } + f6 := func() ([]string, int, io.Reader) { + return []string{"foo", "bar", "baz"}, 42, bytes.NewBufferString("foo") + } + + t.Run("nil", testExec(testCase{impl: f0, command: "foo"}, "", "")) + t.Run("simple", testExec(testCase{impl: f1, command: "foo"}, "", "42")) + t.Run("stringer", testExec(testCase{impl: f2, command: "foo"}, "", "9s")) + t.Run("pointer", testExec(testCase{impl: f3, command: "foo"}, "", "42")) + t.Run("complex", testExec(testCase{impl: f4, command: "foo"}, "", "chan int")) + t.Run("reader", testExec(testCase{impl: f5, command: "foo"}, "", "foo")) + t.Run("mixed", testExec(testCase{impl: f6, command: "foo"}, "", "foo\nbar\nbaz\n42\nfoo")) }