feat: per-file example tests — action, registry, fs, api, string, path, service, error, array
33 new examples across 8 dedicated files. Removed phantom CleanPath
(in RFC spec but never implemented — spec drift caught by examples).
545 tests total, 84.8% coverage. Every major primitive has compilable
examples that serve as test, documentation seed, and godoc content.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 18:29:24 +00:00
|
|
|
package core_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
. "dappco.re/go/core"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func ExampleServiceFor() {
|
|
|
|
|
c := New(
|
|
|
|
|
WithService(func(c *Core) Result {
|
|
|
|
|
return c.Service("cache", Service{
|
|
|
|
|
OnStart: func() Result { return Result{OK: true} },
|
|
|
|
|
})
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
svc := c.Service("cache")
|
feat: eliminate fmt, string concat — add core.Println, use Concat/Path everywhere
New primitive: core.Println() wraps fmt.Println.
Replaced across all test + example files:
- fmt.Println → Println (17 example files)
- fmt.Sprintf → Concat + Sprint
- dir + "/file" → Path(dir, "file") (path security)
- "str" + var → Concat("str", var) (AX consistency)
"fmt" import is now zero across all test files.
String concat with + is zero across all test files.
Remaining 9 stdlib imports (all Go infrastructure):
testing, context, time, sync, embed, io/fs, bytes, gzip, base64
558 tests, 84.5% coverage.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 19:42:39 +00:00
|
|
|
Println(svc.OK)
|
feat: per-file example tests — action, registry, fs, api, string, path, service, error, array
33 new examples across 8 dedicated files. Removed phantom CleanPath
(in RFC spec but never implemented — spec drift caught by examples).
545 tests total, 84.8% coverage. Every major primitive has compilable
examples that serve as test, documentation seed, and godoc content.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 18:29:24 +00:00
|
|
|
// Output: true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ExampleWithService() {
|
|
|
|
|
started := false
|
|
|
|
|
c := New(
|
|
|
|
|
WithService(func(c *Core) Result {
|
|
|
|
|
return c.Service("worker", Service{
|
|
|
|
|
OnStart: func() Result { started = true; return Result{OK: true} },
|
|
|
|
|
})
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
c.ServiceStartup(context.Background(), nil)
|
feat: eliminate fmt, string concat — add core.Println, use Concat/Path everywhere
New primitive: core.Println() wraps fmt.Println.
Replaced across all test + example files:
- fmt.Println → Println (17 example files)
- fmt.Sprintf → Concat + Sprint
- dir + "/file" → Path(dir, "file") (path security)
- "str" + var → Concat("str", var) (AX consistency)
"fmt" import is now zero across all test files.
String concat with + is zero across all test files.
Remaining 9 stdlib imports (all Go infrastructure):
testing, context, time, sync, embed, io/fs, bytes, gzip, base64
558 tests, 84.5% coverage.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 19:42:39 +00:00
|
|
|
Println(started)
|
feat: per-file example tests — action, registry, fs, api, string, path, service, error, array
33 new examples across 8 dedicated files. Removed phantom CleanPath
(in RFC spec but never implemented — spec drift caught by examples).
545 tests total, 84.8% coverage. Every major primitive has compilable
examples that serve as test, documentation seed, and godoc content.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 18:29:24 +00:00
|
|
|
c.ServiceShutdown(context.Background())
|
|
|
|
|
// Output: true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ExampleWithServiceLock() {
|
|
|
|
|
c := New(
|
|
|
|
|
WithService(func(c *Core) Result {
|
|
|
|
|
return c.Service("allowed", Service{})
|
|
|
|
|
}),
|
|
|
|
|
WithServiceLock(),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Can't register after lock
|
|
|
|
|
r := c.Service("blocked", Service{})
|
feat: eliminate fmt, string concat — add core.Println, use Concat/Path everywhere
New primitive: core.Println() wraps fmt.Println.
Replaced across all test + example files:
- fmt.Println → Println (17 example files)
- fmt.Sprintf → Concat + Sprint
- dir + "/file" → Path(dir, "file") (path security)
- "str" + var → Concat("str", var) (AX consistency)
"fmt" import is now zero across all test files.
String concat with + is zero across all test files.
Remaining 9 stdlib imports (all Go infrastructure):
testing, context, time, sync, embed, io/fs, bytes, gzip, base64
558 tests, 84.5% coverage.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 19:42:39 +00:00
|
|
|
Println(r.OK)
|
feat: per-file example tests — action, registry, fs, api, string, path, service, error, array
33 new examples across 8 dedicated files. Removed phantom CleanPath
(in RFC spec but never implemented — spec drift caught by examples).
545 tests total, 84.8% coverage. Every major primitive has compilable
examples that serve as test, documentation seed, and godoc content.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 18:29:24 +00:00
|
|
|
// Output: false
|
|
|
|
|
}
|