サンプル
github.com/frankban/quicktest v1.14.6: New
検証済みサンプル — golang github.com/frankban/quicktest v1.14.6: New. go 1.26 · linux debian/x64 · docker で contract を実行し、成功しました: qt.New initializes a quicktest…
sha256:8610830ef10706b5427900b5c4819fdccfd8d972ff613d346b4638d449d5f048
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
linux 24 · ubuntu · glibc 2.39 x64 go
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-09-06 |
ケース
HOW- ゴール
- verify pkg:golang/github.com/frankban/quicktest@v1.14.6
- シンボル
-
- github.com/frankban/quicktest.New
- 作成日
- 2026-09-06T18:09:40Z
コントラクト
- qt.New initializes a quicktest checker *C embedding the provided testing.TB
- c.Assert evaluates checker assertions and invokes TB.Fatal on failure while allowing execution to proceed on pass
- c.Check evaluates checker assertions and invokes TB.Error without terminating execution, returning boolean pass outcome
- c.Defer registers cleanup functions executed in last-in-first-out order when c.Done is called
- c.Run executes a scoped subtest with an isolated child *C instance inheriting the parent configuration
- c.SetFormat configures custom value printing used across checker failure diagnostics
ファイル
- PROMPT.md
- contract_test.go
- csx.json
- go.mod
- go.sum
- spec.json
ソース
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:golang/github.com/frankban/quicktest@v1.14.6
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/frankban/quicktest@v1.14.6
Demonstrate these symbols/APIs:
- github.com/frankban/quicktest.New
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
package sample_test
import (
"fmt"
"strings"
"testing"
qt "github.com/frankban/quicktest"
)
// tbSpy embeds testing.TB to capture Error and Fatal calls without halting the test runner.
type tbSpy struct {
testing.TB
failed bool
fataled bool
errorBuf strings.Builder
fatalBuf strings.Builder
}
func (s *tbSpy) Helper() {}
func (s *tbSpy) Error(args ...interface{}) {
s.failed = true
s.errorBuf.WriteString(fmt.Sprint(args...))
}
func (s *tbSpy) Fatal(args ...interface{}) {
s.failed = true
s.fataled = true
s.fatalBuf.WriteString(fmt.Sprint(args...))
}
// Contract 1: qt.New initializes a quicktest checker *C embedding the provided testing.TB
func TestNewInitialization(t *testing.T) {
c := qt.New(t)
if c == nil {
t.Fatal("expected non-nil *qt.C from qt.New")
}
if c.TB != t {
t.Fatalf("expected embedded TB to match provided testing.TB, got %p want %p", c.TB, t)
}
}
// Contract 2: c.Assert evaluates checker assertions and invokes TB.Fatal on failure while allowing execution to proceed on pass
func TestCAssert(t *testing.T) {
// Passing assertion: returns true, no fatal recorded
spyPass := &tbSpy{TB: t}
cPass := qt.New(spyPass)
ok := cPass.Assert(42, qt.Equals, 42)
if !ok || spyPass.fataled || spyPass.failed {
t.Fatalf("expected Assert to pass cleanly, got ok=%v, fataled=%v", ok, spyPass.fataled)
}
// Failing assertion: calls TB.Fatal, returns false, failure details formatted
spyFail := &tbSpy{TB: t}
cFail := qt.New(spyFail)
ok = cFail.Assert("apple", qt.Equals, "orange")
if ok {
t.Fatal("expected Assert to return false on mismatched values")
}
if !spyFail.fataled || !spyFail.failed {
t.Fatal("expected TB.Fatal to be called on assertion failure")
}
out := spyFail.fatalBuf.String()
if !strings.Contains(out, "values are not equal") || !strings.Contains(out, "apple") || !strings.Contains(out, "orange") {
t.Fatalf("expected failure report with diff details, got: %s", out)
}
}
// Contract 3: c.Check evaluates checker assertions and invokes TB.Error without terminating execution, returning boolean pass outcome
func TestCCheck(t *testing.T) {
spy := &tbSpy{TB: t}
c := qt.New(spy)
// Passing check
okPass := c.Check([]int{1, 2}, qt.DeepEquals, []int{1, 2})
if !okPass || spy.failed {
t.Fatalf("expected Check to return true without failure, got ok=%v, failed=%v", okPass, spy.failed)
}
// Failing check: records Error, does NOT record Fatal, returns false
okFail := c.Check([]int{1, 2}, qt.DeepEquals, []int{1, 3})
if okFail {
t.Fatal("expected Check to return false on mismatch")
}
if !spy.failed {
t.Fatal("expected TB.Error to be recorded on check failure")
}
if spy.fataled {
t.Fatal("Check should not call TB.Fatal")
}
errOut := spy.errorBuf.String()
if !strings.Contains(errOut, "values are not deep equal") {
t.Fatalf("expected error output to describe mismatch, got: %s", errOut)
}
}
// Contract 4: c.Defer registers cleanup functions executed in last-in-first-out order when c.Done is called
func TestCDeferAndDone(t *testing.T) {
var executed []string
t.Run("subtest_with_defer", func(st *testing.T) {
c := qt.New(st)
defer c.Done()
c.Defer(func() {
executed = append(executed, "first_deferred")
})
c.Defer(func() {
executed = append(executed, "second_deferred")
})
if len(executed) != 0 {
st.Fatalf("deferred functions ran prematurely: %v", executed)
}
})
if len(executed) != 2 {
t.Fatalf("expected 2 deferred functions to run upon completion, got %d", len(executed))
}
// LIFO order: second deferred must run before first deferred
if executed[0] != "second_deferred" || executed[1] != "first_deferred" {
t.Fatalf("expected LIFO execution order [second_deferred, first_deferred], got: %v", executed)
}
}
// Contract 5: c.Run executes a scoped subtest with an isolated child *C instance inheriting the parent configuration
func TestCRunSubtest(t *testing.T) {
c := qt.New(t)
ran := false
c.Run("child_subtest", func(childC *qt.C) {
ran = true
if childC == nil {
t.Fatal("subtest received nil *qt.C")
}
if childC == c {
t.Fatal("subtest should receive a new distinct child *qt.C instance")
}
// Child instance assertions work within subtest
childC.Assert("quicktest", qt.Matches, "^quick.*")
})
if !ran {
t.Fatal("c.Run subtest body did not execute")
}
}
// Contract 6: c.SetFormat configures custom value printing used across checker failure diagnostics
func TestCSetFormat(t *testing.T) {
spy := &tbSpy{TB: t}
c := qt.New(spy)
c.SetFormat(func(v interface{}) string {
return fmt.Sprintf("<<<CUSTOM:%v>>>", v)
})
c.Check("valA", qt.Equals, "valB")
out := spy.errorBuf.String()
if !strings.Contains(out, "<<<CUSTOM:valA>>>") || !strings.Contains(out, "<<<CUSTOM:valB>>>") {
t.Fatalf("expected custom formatted values in check output, got: %s", out)
}
}
{"case":{"caseId":"case:sha256:0cc7120e88cc56b993aa11d49d2ac036bb9652e09e38889137dd1e92c626bfc4","contract":["qt.New initializes a quicktest checker *C embedding the provided testing.TB","c.Assert evaluates checker assertions and invokes TB.Fatal on failure while allowing execution to proceed on pass","c.Check evaluates checker assertions and invokes TB.Error without terminating execution, returning boolean pass outcome","c.Defer registers cleanup functions executed in last-in-first-out order when c.Done is called","c.Run executes a scoped subtest with an isolated child *C instance inheriting the parent configuration","c.SetFormat configures custom value printing used across checker failure diagnostics"],"goal":"verify pkg:golang/github.com/frankban/quicktest@v1.14.6","kind":"HOW","packages":["pkg:golang/github.com/frankban/quicktest@v1.14.6"],"schemaVersion":1,"symbols":["github.com/frankban/quicktest.New"]},"contractCommand":["go","test","-v","./..."],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/frankban/quicktest@v1.14.6"],"schemaVersion":1,"subject":"pkg:golang/github.com/frankban/quicktest@v1.14.6","symbols":["github.com/frankban/quicktest.New"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/frankban/quicktest v1.14.6
require (
github.com/google/go-cmp v0.5.9 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
)
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
{
"schemaVersion": 1,
"goal": "verify pkg:golang/github.com/frankban/quicktest@v1.14.6",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/frankban/quicktest@v1.14.6"
],
"symbols": [
"github.com/frankban/quicktest.New"
]
}
オリジンシーダー
匿名