샘플
github.com/frankban/quicktest v1.14.6: PanicMatches
검증된 샘플 — golang github.com/frankban/quicktest v1.14.6: PanicMatches. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:4ac4e2c3f2fab262e86af9f8769f57879f57e7be82593aac103aacb3539121bf
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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 github.com/frankban/quicktest.PanicMatches in pkg:golang/github.com/frankban/quicktest@v1.14.6
- 심벌
-
- github.com/frankban/quicktest.PanicMatches
- 생성일
- 2026-09-06T18:42:46Z
컨트랙트
- qt.PanicMatches succeeds when a zero-argument function panics with a message matching a string pattern or regular expression
- qt.PanicMatches supports pre-compiled *regexp.Regexp pattern arguments
- qt.PanicMatches allows zero-argument functions that return values as long as they panic with a matching message
- qt.PanicMatches fails with a function did not panic error when the checked function terminates normally without panicking
- qt.PanicMatches fails with a panic value does not match regexp error when the panic message does not match the provided pattern
- qt.PanicMatches returns a bad check error when the first argument is not a function or when the function accepts arguments
- qt.PanicMatches returns a bad check error when the pattern argument is neither a string nor a compiled regular expression
파일
- 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 github.com/frankban/quicktest.PanicMatches in 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.PanicMatches
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"
"regexp"
"strings"
"testing"
qt "github.com/frankban/quicktest"
)
// tbSpy captures Error and Fatal calls to verify assertion failure behavior without halting tests.
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.PanicMatches succeeds when a zero-argument function panics with a message matching a string pattern or regular expression
func TestPanicMatchesStringPattern(t *testing.T) {
c := qt.New(t)
// Exact string match
c.Assert(func() {
panic("connection lost: EOF")
}, qt.PanicMatches, "connection lost: EOF")
// Regex string match
c.Assert(func() {
panic("status code: 503 Service Unavailable")
}, qt.PanicMatches, `status code: \d+ .*`)
}
// Contract 2: qt.PanicMatches supports pre-compiled *regexp.Regexp pattern arguments
func TestPanicMatchesCompiledRegexp(t *testing.T) {
c := qt.New(t)
compiled := regexp.MustCompile(`^(alpha|beta|gamma)-\d+$`)
c.Assert(func() {
panic("beta-42")
}, qt.PanicMatches, compiled)
}
// Contract 3: qt.PanicMatches allows zero-argument functions that return values as long as they panic with a matching message
func TestPanicMatchesFuncWithReturn(t *testing.T) {
c := qt.New(t)
c.Assert(func() string {
panic("returned function panicked")
}, qt.PanicMatches, "returned function panicked")
}
// Contract 4: qt.PanicMatches fails with a function did not panic error when the checked function terminates normally without panicking
func TestPanicMatchesNoPanicFailure(t *testing.T) {
spy := &tbSpy{TB: t}
c := qt.New(spy)
ok := c.Check(func() {
// Normal completion without panic
}, qt.PanicMatches, ".*")
if ok {
t.Fatal("expected c.Check to return false when checked function does not panic")
}
if !spy.failed {
t.Fatal("expected TB.Error to be recorded on non-panicking function")
}
if !strings.Contains(spy.errorBuf.String(), "function did not panic") {
t.Fatalf("expected error message to contain 'function did not panic', got: %s", spy.errorBuf.String())
}
}
// Contract 5: qt.PanicMatches fails with a panic value does not match regexp error when the panic message does not match the provided pattern
func TestPanicMatchesMismatchFailure(t *testing.T) {
spy := &tbSpy{TB: t}
c := qt.New(spy)
ok := c.Check(func() {
panic("operation timed out")
}, qt.PanicMatches, "^file not found$")
if ok {
t.Fatal("expected c.Check to return false on mismatched pattern")
}
if !spy.failed {
t.Fatal("expected TB.Error to be recorded on pattern mismatch")
}
if !strings.Contains(spy.errorBuf.String(), "panic value does not match regexp") {
t.Fatalf("expected error message to contain 'panic value does not match regexp', got: %s", spy.errorBuf.String())
}
}
// Contract 6: qt.PanicMatches returns a bad check error when the first argument is not a function or when the function accepts arguments
func TestPanicMatchesInvalidFunctionArg(t *testing.T) {
// Not a function
spyNotFunc := &tbSpy{TB: t}
cNotFunc := qt.New(spyNotFunc)
ok := cNotFunc.Check("not-a-func", qt.PanicMatches, ".*")
if ok || !spyNotFunc.failed {
t.Fatal("expected failure when first argument is not a function")
}
if !strings.Contains(spyNotFunc.errorBuf.String(), "first argument is not a function") {
t.Fatalf("expected 'first argument is not a function', got: %s", spyNotFunc.errorBuf.String())
}
// Function receiving arguments
spyWithArgs := &tbSpy{TB: t}
cWithArgs := qt.New(spyWithArgs)
ok = cWithArgs.Check(func(code int) {
panic("panic with code")
}, qt.PanicMatches, ".*")
if ok || !spyWithArgs.failed {
t.Fatal("expected failure when function takes arguments")
}
if !strings.Contains(spyWithArgs.errorBuf.String(), "cannot use a function receiving arguments") {
t.Fatalf("expected 'cannot use a function receiving arguments', got: %s", spyWithArgs.errorBuf.String())
}
}
// Contract 7: qt.PanicMatches returns a bad check error when the pattern argument is neither a string nor a compiled regular expression
func TestPanicMatchesInvalidPatternArg(t *testing.T) {
spy := &tbSpy{TB: t}
c := qt.New(spy)
ok := c.Check(func() {
panic("some panic")
}, qt.PanicMatches, 12345)
if ok || !spy.failed {
t.Fatal("expected failure when pattern argument is not a string or *regexp.Regexp")
}
if !strings.Contains(spy.errorBuf.String(), "regexp is not a string") {
t.Fatalf("expected 'regexp is not a string', got: %s", spy.errorBuf.String())
}
}
{"case":{"caseId":"case:sha256:e37a1a8bf2683087957eeb9bdcbc36efcfd88c07d260b09327c0982d4413cc1c","contract":["qt.PanicMatches succeeds when a zero-argument function panics with a message matching a string pattern or regular expression","qt.PanicMatches supports pre-compiled *regexp.Regexp pattern arguments","qt.PanicMatches allows zero-argument functions that return values as long as they panic with a matching message","qt.PanicMatches fails with a function did not panic error when the checked function terminates normally without panicking","qt.PanicMatches fails with a panic value does not match regexp error when the panic message does not match the provided pattern","qt.PanicMatches returns a bad check error when the first argument is not a function or when the function accepts arguments","qt.PanicMatches returns a bad check error when the pattern argument is neither a string nor a compiled regular expression"],"goal":"verify github.com/frankban/quicktest.PanicMatches in 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.PanicMatches"]},"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.PanicMatches"],"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 github.com/frankban/quicktest.PanicMatches in 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.PanicMatches"
]
}
오리진 시더
익명