샘플
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
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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"
]
}
오리진 시더
익명