| 1 |
rsc.io/[email protected] |
| 2 |
|
| 3 |
-- .mod -- |
| 4 |
module rsc.io/quote |
| 5 |
|
| 6 |
require ( |
| 7 |
rsc.io/quote/v3 v3.0.0 |
| 8 |
rsc.io/sampler v1.3.0 |
| 9 |
) |
| 10 |
-- .info -- |
| 11 |
{"Version":"v0.0.0-20180710144737-5d9f230bcfba","Name":"5d9f230bcfbae514bb6c2215694c2ce7273fc604","Short":"5d9f230bcfba","Time":"2018-07-10T14:47:37Z"} |
| 12 |
-- buggy/buggy_test.go -- |
| 13 |
// Copyright 2018 The Go Authors. All rights reserved. |
| 14 |
// Use of this source code is governed by a BSD-style |
| 15 |
// license that can be found in the LICENSE file. |
| 16 |
|
| 17 |
package buggy |
| 18 |
|
| 19 |
import "testing" |
| 20 |
|
| 21 |
func Test(t *testing.T) { |
| 22 |
t.Fatal("buggy!") |
| 23 |
} |
| 24 |
-- go.mod -- |
| 25 |
module rsc.io/quote |
| 26 |
|
| 27 |
require ( |
| 28 |
rsc.io/quote/v3 v3.0.0 |
| 29 |
rsc.io/sampler v1.3.0 |
| 30 |
) |
| 31 |
-- quote.go -- |
| 32 |
// Copyright 2018 The Go Authors. All rights reserved. |
| 33 |
// Use of this source code is governed by a BSD-style |
| 34 |
// license that can be found in the LICENSE file. |
| 35 |
|
| 36 |
// Package quote collects pithy sayings. |
| 37 |
package quote // import "rsc.io/quote" |
| 38 |
|
| 39 |
import "rsc.io/quote/v3" |
| 40 |
|
| 41 |
// Hello returns a greeting. |
| 42 |
func Hello() string { |
| 43 |
return quote.HelloV3() |
| 44 |
} |
| 45 |
|
| 46 |
// Glass returns a useful phrase for world travelers. |
| 47 |
func Glass() string { |
| 48 |
// See http://www.oocities.org/nodotus/hbglass.html. |
| 49 |
return quote.GlassV3() |
| 50 |
} |
| 51 |
|
| 52 |
// Go returns a Go proverb. |
| 53 |
func Go() string { |
| 54 |
return quote.GoV3() |
| 55 |
} |
| 56 |
|
| 57 |
// Opt returns an optimization truth. |
| 58 |
func Opt() string { |
| 59 |
// Wisdom from ken. |
| 60 |
return quote.OptV3() |
| 61 |
} |
| 62 |
-- quote_test.go -- |
| 63 |
// Copyright 2018 The Go Authors. All rights reserved. |
| 64 |
// Use of this source code is governed by a BSD-style |
| 65 |
// license that can be found in the LICENSE file. |
| 66 |
|
| 67 |
package quote |
| 68 |
|
| 69 |
import ( |
| 70 |
"os" |
| 71 |
"testing" |
| 72 |
) |
| 73 |
|
| 74 |
func init() { |
| 75 |
os.Setenv("LC_ALL", "en") |
| 76 |
} |
| 77 |
|
| 78 |
func TestHello(t *testing.T) { |
| 79 |
hello := "Hello, world." |
| 80 |
if out := Hello(); out != hello { |
| 81 |
t.Errorf("Hello() = %q, want %q", out, hello) |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
func TestGlass(t *testing.T) { |
| 86 |
glass := "I can eat glass and it doesn't hurt me." |
| 87 |
if out := Glass(); out != glass { |
| 88 |
t.Errorf("Glass() = %q, want %q", out, glass) |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
func TestGo(t *testing.T) { |
| 93 |
go1 := "Don't communicate by sharing memory, share memory by communicating." |
| 94 |
if out := Go(); out != go1 { |
| 95 |
t.Errorf("Go() = %q, want %q", out, go1) |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
func TestOpt(t *testing.T) { |
| 100 |
opt := "If a program is too slow, it must have a loop." |
| 101 |
if out := Opt(); out != opt { |
| 102 |
t.Errorf("Opt() = %q, want %q", out, opt) |
| 103 |
} |
| 104 |
} |