...

Text file src/cmd/go/testdata/mod/rsc.io_quote_v0.0.0-20180628003336-dd9747d19b04.txt

Documentation: cmd/go/testdata/mod

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

View as plain text