]> Cypherpunks repositories - gostls13.git/commitdiff
convert low-level (used by testing) packages to
authorRuss Cox <rsc@golang.org>
Wed, 12 Aug 2009 20:18:37 +0000 (13:18 -0700)
committerRuss Cox <rsc@golang.org>
Wed, 12 Aug 2009 20:18:37 +0000 (13:18 -0700)
whole-package compilation.  new Makefiles,
tests now in separate package

bytes
flag
fmt
io
math
once
os
reflect
strconv
sync
time
utf8

delete import "xxx" in package xxx.

inside package xxx, xxx is not declared
anymore so s/xxx.//g

delete file and package level forward declarations.

note the new internal_test.go and sync
and strconv to provide public access to
internals during testing.  the installed version
of the package omits that file and thus does
not open the internals to all clients.

R=r
OCL=33065
CL=33097

81 files changed:
src/pkg/bytes/Makefile
src/pkg/bytes/buffer.go
src/pkg/bytes/buffer_test.go
src/pkg/bytes/bytes_test.go
src/pkg/flag/Makefile
src/pkg/flag/flag.go
src/pkg/flag/flag_test.go
src/pkg/fmt/Makefile
src/pkg/fmt/fmt_test.go
src/pkg/fmt/print.go
src/pkg/io/Makefile
src/pkg/io/pipe.go
src/pkg/io/pipe_test.go
src/pkg/io/utils.go
src/pkg/io/utils_test.go
src/pkg/math/Makefile
src/pkg/math/all_test.go
src/pkg/math/asin.go
src/pkg/math/atan.go
src/pkg/math/atan2.go
src/pkg/math/exp.go
src/pkg/math/floor.go
src/pkg/math/fmod.go
src/pkg/math/log.go
src/pkg/math/pow.go
src/pkg/math/sin.go
src/pkg/math/sinh.go
src/pkg/math/sqrt.go
src/pkg/math/tan.go
src/pkg/math/tanh.go
src/pkg/once/Makefile
src/pkg/once/once_test.go
src/pkg/os/Makefile
src/pkg/os/dir_darwin_386.go
src/pkg/os/dir_darwin_amd64.go
src/pkg/os/dir_linux_386.go
src/pkg/os/dir_linux_amd64.go
src/pkg/os/env.go
src/pkg/os/exec.go
src/pkg/os/file.go
src/pkg/os/getwd.go
src/pkg/os/os_test.go
src/pkg/os/path.go
src/pkg/os/path_test.go
src/pkg/os/proc.go
src/pkg/os/stat_darwin_386.go
src/pkg/os/stat_darwin_amd64.go
src/pkg/os/stat_linux_386.go
src/pkg/os/stat_linux_amd64.go
src/pkg/os/sys_darwin.go
src/pkg/os/sys_linux.go
src/pkg/os/time.go
src/pkg/reflect/Makefile
src/pkg/reflect/all_test.go
src/pkg/reflect/deepequal.go
src/pkg/reflect/tostring_test.go [moved from src/pkg/reflect/tostring.go with 94% similarity]
src/pkg/reflect/type.go
src/pkg/reflect/value.go
src/pkg/strconv/Makefile
src/pkg/strconv/atof.go
src/pkg/strconv/atof_test.go
src/pkg/strconv/atoi.go
src/pkg/strconv/atoi_test.go
src/pkg/strconv/decimal.go
src/pkg/strconv/decimal_test.go
src/pkg/strconv/fp_test.go
src/pkg/strconv/ftoa.go
src/pkg/strconv/ftoa_test.go
src/pkg/strconv/internal_test.go [new file with mode: 0644]
src/pkg/strconv/itoa_test.go
src/pkg/strconv/quote_test.go
src/pkg/sync/Makefile
src/pkg/sync/internal_test.go [new file with mode: 0644]
src/pkg/sync/mutex_test.go
src/pkg/time/Makefile
src/pkg/time/tick.go
src/pkg/time/tick_test.go
src/pkg/time/time.go
src/pkg/time/time_test.go
src/pkg/utf8/Makefile
src/pkg/utf8/utf8_test.go

index 96071221c613b6dcebc24f217b8b040c6aa98aea..6d7d113e69fb96fa571fc460eadfe625fde932af 100644 (file)
@@ -2,61 +2,11 @@
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
-
-# DO NOT EDIT.  Automatically generated by gobuild.
-# gobuild -m >Makefile
-
-D=
-
 include $(GOROOT)/src/Make.$(GOARCH)
-AR=gopack
-
-default: packages
-
-clean:
-       rm -rf *.[$(OS)] *.a [$(OS)].out _obj
-
-test: packages
-       gotest
-
-coverage: packages
-       gotest
-       6cov -g $$(pwd) | grep -v '_test\.go:'
-
-%.$O: %.go
-       $(GC) -I_obj $*.go
-
-%.$O: %.c
-       $(CC) $*.c
-
-%.$O: %.s
-       $(AS) $*.s
-
-O1=\
-       buffer.$O\
-       bytes.$O\
-
-
-phases: a1
-_obj$D/bytes.a: phases
-
-a1: $(O1)
-       $(AR) grc _obj$D/bytes.a buffer.$O bytes.$O
-       rm -f $(O1)
-
-
-newpkg: clean
-       mkdir -p _obj$D
-       $(AR) grc _obj$D/bytes.a
-
-$(O1): newpkg
-$(O2): a1
-
-nuke: clean
-       rm -f $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/bytes.a
 
-packages: _obj$D/bytes.a
+TARG=bytes
+GOFILES=\
+       buffer.go\
+       bytes.go\
 
-install: packages
-       test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D
-       cp _obj$D/bytes.a $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/bytes.a
+include $(GOROOT)/src/Make.pkg
index 58e06e9e4d11dfb4364d9ab7caefacc0e31deedd..6c857069b081bd3c12f0cb2a42ae8e3f247d9ff5 100644 (file)
@@ -7,7 +7,6 @@ package bytes
 // Simple byte buffer for marshaling data.
 
 import (
-       "bytes";
        "os";
 )
 
index 76078882c26e143917f1b6a55b95d18a62d7f25e..4d3fca87273f010ed5e92df4136b254c6e27f710 100644 (file)
@@ -2,10 +2,10 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package bytes
+package bytes_test
 
 import (
-       "bytes";
+       "bytes";
        "rand";
        "testing";
 )
index a3e44262cc202e608ebdd79994631a55db868135..e37767d9a244364386f17c6432058a6109c040e0 100644 (file)
@@ -2,10 +2,10 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package bytes
+package bytes_test
 
 import (
-       "bytes";
+       "bytes";
        "strings";
        "testing";
 )
@@ -85,7 +85,7 @@ var explodetests = []ExplodeTest {
 }
 func TestExplode(t *testing.T) {
        for _, tt := range(explodetests) {
-               a := explode(strings.Bytes(tt.s), tt.n);
+               a := Split(strings.Bytes(tt.s), nil, tt.n);
                result := arrayOfString(a);
                if !eq(result, tt.a) {
                        t.Errorf(`Explode("%s", %d) = %v; want %v`, tt.s, tt.n, result, tt.a);
index 466e19564cf9c343a04dbfa8efc496b2a3bccecb..faa95185cacb63a63ce5f11bec96b2bf4857accd 100644 (file)
@@ -2,59 +2,10 @@
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
-# DO NOT EDIT.  Automatically generated by gobuild.
-# gobuild -m >Makefile
-
-D=
-
 include $(GOROOT)/src/Make.$(GOARCH)
-AR=gopack
-
-default: packages
-
-clean:
-       rm -rf *.[$(OS)] *.a [$(OS)].out _obj
-
-test: packages
-       gotest
-
-coverage: packages
-       gotest
-       6cov -g `pwd` | grep -v '_test\.go:'
-
-%.$O: %.go
-       $(GC) -I_obj $*.go
-
-%.$O: %.c
-       $(CC) $*.c
-
-%.$O: %.s
-       $(AS) $*.s
-
-O1=\
-       flag.$O\
-
-
-phases: a1
-_obj$D/flag.a: phases
-
-a1: $(O1)
-       $(AR) grc _obj$D/flag.a flag.$O
-       rm -f $(O1)
-
-
-newpkg: clean
-       mkdir -p _obj$D
-       $(AR) grc _obj$D/flag.a
-
-$(O1): newpkg
-$(O2): a1
-
-nuke: clean
-       rm -f $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/flag.a
 
-packages: _obj$D/flag.a
+TARG=flag
+GOFILES=\
+       flag.go\
 
-install: packages
-       test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D
-       cp _obj$D/flag.a $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/flag.a
+include $(GOROOT)/src/Make.pkg
index 7e4f6dc173a0fde53d2965cdae2c3ed732a0bc9d..9927886435724ef2d5ccdf9975f065269abdcb10 100644 (file)
@@ -8,7 +8,7 @@
        Usage:
 
        1) Define flags using flag.String(), Bool(), Int(), etc. Example:
-               import flag "flag"
+               import "flag"
                var ip *int = flag.Int("flagname", 1234, "help message for flagname")
        If you like, you can bind the flag to a variable using the Var() functions.
                var flagvar int
index 0d83fcf81e79f0c9fbc687bd9a71fc98508e4ab4..259d507ed7617bb6ec6a040ce5186cf27ff8c883 100644 (file)
@@ -2,21 +2,21 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package flag
+package flag_test
 
 import (
-       "flag";
+       "flag";
        "fmt";
        "testing";
 )
 
 var (
-       test_bool = flag.Bool("test_bool", false, "bool value");
-       test_int = flag.Int("test_int", 0, "int value");
-       test_int64 = flag.Int64("test_int64", 0, "int64 value");
-       test_uint = flag.Uint("test_uint", 0, "uint value");
-       test_uint64 = flag.Uint64("test_uint64", 0, "uint64 value");
-       test_string = flag.String("test_string", "0", "string value");
+       test_bool = Bool("test_bool", false, "bool value");
+       test_int = Int("test_int", 0, "int value");
+       test_int64 = Int64("test_int64", 0, "int64 value");
+       test_uint = Uint("test_uint", 0, "uint value");
+       test_uint64 = Uint64("test_uint64", 0, "uint64 value");
+       test_string = String("test_string", "0", "string value");
 )
 
 func boolString(s string) string {
@@ -27,9 +27,9 @@ func boolString(s string) string {
 }
 
 func TestEverything(t *testing.T) {
-       m := make(map[string] *flag.Flag);
+       m := make(map[string] *Flag);
        desired := "0";
-       visitor := func(f *flag.Flag) {
+       visitor := func(f *Flag) {
                if len(f.Name) > 5 && f.Name[0:5] == "test_" {
                        m[f.Name] = f;
                        ok := false;
@@ -40,36 +40,36 @@ func TestEverything(t *testing.T) {
                                ok = true;
                        }
                        if !ok {
-                               t.Error("flag.Visit: bad value", f.Value.String(), "for", f.Name);
+                               t.Error("Visit: bad value", f.Value.String(), "for", f.Name);
                        }
                }
        };
-       flag.VisitAll(visitor);
+       VisitAll(visitor);
        if len(m) != 6 {
-               t.Error("flag.VisitAll misses some flags");
+               t.Error("VisitAll misses some flags");
                for k, v := range m {
                        t.Log(k, *v)
                }
        }
-       m = make(map[string] *flag.Flag);
-       flag.Visit(visitor);
+       m = make(map[string] *Flag);
+       Visit(visitor);
        if len(m) != 0 {
-               t.Errorf("flag.Visit sees unset flags");
+               t.Errorf("Visit sees unset flags");
                for k, v := range m {
                        t.Log(k, *v)
                }
        }
        // Now set all flags
-       flag.Set("test_bool", "true");
-       flag.Set("test_int", "1");
-       flag.Set("test_int64", "1");
-       flag.Set("test_uint", "1");
-       flag.Set("test_uint64", "1");
-       flag.Set("test_string", "1");
+       Set("test_bool", "true");
+       Set("test_int", "1");
+       Set("test_int64", "1");
+       Set("test_uint", "1");
+       Set("test_uint64", "1");
+       Set("test_string", "1");
        desired = "1";
-       flag.Visit(visitor);
+       Visit(visitor);
        if len(m) != 6 {
-               t.Error("flag.Visit fails after set");
+               t.Error("Visit fails after set");
                for k, v := range m {
                        t.Log(k, *v)
                }
index 5d0281a0c3be4e320fbf24ea0159a01b0212bbb3..9273093e8924df590890c8a81c8ffa849e19d5f8 100644 (file)
@@ -2,67 +2,11 @@
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
-# DO NOT EDIT.  Automatically generated by gobuild.
-# gobuild -m >Makefile
-
-D=
-
 include $(GOROOT)/src/Make.$(GOARCH)
-AR=gopack
-
-default: packages
-
-clean:
-       rm -rf *.[$(OS)] *.a [$(OS)].out _obj
-
-test: packages
-       gotest
-
-coverage: packages
-       gotest
-       6cov -g `pwd` | grep -v '_test\.go:'
-
-%.$O: %.go
-       $(GC) -I_obj $*.go
-
-%.$O: %.c
-       $(CC) $*.c
-
-%.$O: %.s
-       $(AS) $*.s
-
-O1=\
-       format.$O\
-
-O2=\
-       print.$O\
-
-
-phases: a1 a2
-_obj$D/fmt.a: phases
-
-a1: $(O1)
-       $(AR) grc _obj$D/fmt.a format.$O
-       rm -f $(O1)
-
-a2: $(O2)
-       $(AR) grc _obj$D/fmt.a print.$O
-       rm -f $(O2)
-
-
-newpkg: clean
-       mkdir -p _obj$D
-       $(AR) grc _obj$D/fmt.a
-
-$(O1): newpkg
-$(O2): a1
-$(O3): a2
-
-nuke: clean
-       rm -f $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/fmt.a
 
-packages: _obj$D/fmt.a
+TARG=fmt
+GOFILES=\
+       format.go\
+       print.go\
 
-install: packages
-       test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D
-       cp _obj$D/fmt.a $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/fmt.a
+include $(GOROOT)/src/Make.pkg
index 9d772e1befad5afb656b2f2445bfe5dd14c6d703..76234e552b2ef3ef7086ee3402b27a981c16ab78 100644 (file)
@@ -2,10 +2,10 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package fmt
+package fmt_test
 
 import (
-       "fmt";
+       "fmt";
        "io";
        "math";
        "strings";
index 86a09879e5847784933665c315a50eac18fda203..bb1030e726b27468c33fb7cc6ca9f8039a9e652f 100644 (file)
@@ -74,7 +74,6 @@ package fmt
 
 
 import (
-       "fmt";
        "io";
        "os";
        "reflect";
@@ -198,9 +197,6 @@ func (p *pp) Write(b []byte) (ret int, err os.Error) {
        return len(b), nil;
 }
 
-func (p *pp) doprintf(format string, v *reflect.StructValue);
-func (p *pp) doprint(v *reflect.StructValue, addspace, addnewline bool);
-
 // These routines end in 'f' and take a format string.
 
 // Fprintf formats according to a format specifier and writes to w.
index eb3a966ad0a96092dd18c08bb04b411d7de26fe4..bf124f4549eb3424dd81190cc12979b4ac8111ea 100644 (file)
@@ -2,69 +2,12 @@
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
-
-# DO NOT EDIT.  Automatically generated by gobuild.
-# gobuild -m >Makefile
-
-D=
-
 include $(GOROOT)/src/Make.$(GOARCH)
-AR=gopack
-
-default: packages
-
-clean:
-       rm -rf *.[$(OS)] *.a [$(OS)].out _obj
-
-test: packages
-       gotest
-
-coverage: packages
-       gotest
-       6cov -g $$(pwd) | grep -v '_test\.go:'
-
-%.$O: %.go
-       $(GC) -I_obj $*.go
-
-%.$O: %.c
-       $(CC) $*.c
-
-%.$O: %.s
-       $(AS) $*.s
-
-O1=\
-       io.$O\
-       pipe.$O\
-
-O2=\
-       utils.$O\
-
-
-phases: a1 a2
-_obj$D/io.a: phases
-
-a1: $(O1)
-       $(AR) grc _obj$D/io.a io.$O pipe.$O
-       rm -f $(O1)
-
-a2: $(O2)
-       $(AR) grc _obj$D/io.a utils.$O
-       rm -f $(O2)
-
-
-newpkg: clean
-       mkdir -p _obj$D
-       $(AR) grc _obj$D/io.a
-
-$(O1): newpkg
-$(O2): a1
-$(O3): a2
-
-nuke: clean
-       rm -f $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/io.a
 
-packages: _obj$D/io.a
+TARG=io
+GOFILES=\
+       io.go\
+       pipe.go\
+       utils.go\
 
-install: packages
-       test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D
-       cp _obj$D/io.a $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/io.a
+include $(GOROOT)/src/Make.pkg
index 729094fde3e65b384552f3c2b94f63e0a6e4e7d5..151f3ca68ea8d7bbc58d8312fd250a62d055d2cc 100644 (file)
@@ -8,7 +8,6 @@
 package io
 
 import (
-       "io";
        "os";
        "sync";
 )
index 6b36cc6fcb165b39e27672ec7040215b8e13af5f..f9363769739c1f1bdc38493bbcb3a00371116660 100644 (file)
@@ -2,11 +2,11 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package io
+package io_test
 
 import (
        "fmt";
-       "io";
+       "io";
        "os";
        "strings";
        "testing";
@@ -84,6 +84,11 @@ func TestPipe2(t *testing.T) {
        }
 }
 
+type pipeReturn struct {
+       n int;
+       err os.Error;
+}
+
 // Test a large write that requires multiple reads to satisfy.
 func writer(w WriteCloser, buf []byte, c chan pipeReturn) {
        n, err := w.Write(buf);
@@ -156,10 +161,10 @@ func (p pipeTest) String() string {
 var pipeTests = []pipeTest {
        pipeTest{ true, nil, false },
        pipeTest{ true, nil, true },
-       pipeTest{ true, io.ErrShortWrite, true },
+       pipeTest{ true, ErrShortWrite, true },
        pipeTest{ false, nil, false },
        pipeTest{ false, nil, true },
-       pipeTest{ false, io.ErrShortWrite, true },
+       pipeTest{ false, ErrShortWrite, true },
 }
 
 func delayClose(t *testing.T, cl closer, ch chan int, tt pipeTest) {
index 23acfb4ef173479e0798ce067a3b854c359b500d..45dd5f9a4cde3672dc12a4c94c9cc6b5118689b2 100644 (file)
@@ -8,7 +8,6 @@ package io
 
 import (
        "bytes";
-       "io";
        "os";
 )
 
index 4538337436e35a767de533e041b9d9fdf13f6a38..a16a40b574a80fd28a1bec23b3fbc4e2a68016b2 100644 (file)
@@ -2,10 +2,10 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package io
+package io_test
 
 import (
-       "io";
+       "io";
        "os";
        "strings";
        "testing";
index 058049072f33df4ca0538a9c02613cbf45b92db0..f062a7468b92d21291d6fca9a493b88d0b44fc0c 100644 (file)
@@ -2,97 +2,27 @@
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
-# DO NOT EDIT.  Automatically generated by gobuild.
-# gobuild -m >Makefile
-
-D=
-
 include $(GOROOT)/src/Make.$(GOARCH)
-AR=gopack
-
-default: packages
-
-clean:
-       rm -rf *.[$(OS)] *.a [$(OS)].out _obj
-
-test: packages
-       gotest
-
-coverage: packages
-       gotest
-       6cov -g `pwd` | grep -v '_test\.go:'
-
-%.$O: %.go
-       $(GC) -I_obj $*.go
-
-%.$O: %.c
-       $(CC) $*.c
-
-%.$O: %.s
-       $(AS) $*.s
-
-O1=\
-       const.$O\
-       fabs.$O\
-       hypot.$O\
-       pow10.$O\
-       runtime.$O\
-
-O2=\
-       atan.$O\
-       exp.$O\
-       floor.$O\
-       fmod.$O\
-       log.$O\
-       sin.$O\
-       sqrt.$O\
-       tan.$O\
-
-O3=\
-       asin.$O\
-       atan2.$O\
-       pow.$O\
-       sinh.$O\
-
-O4=\
-       tanh.$O\
-
-
-phases: a1 a2 a3 a4
-_obj$D/math.a: phases
-
-a1: $(O1)
-       $(AR) grc _obj$D/math.a const.$O fabs.$O hypot.$O pow10.$O runtime.$O
-       rm -f $(O1)
-
-a2: $(O2)
-       $(AR) grc _obj$D/math.a atan.$O exp.$O floor.$O fmod.$O log.$O sin.$O sqrt.$O tan.$O
-       rm -f $(O2)
-
-a3: $(O3)
-       $(AR) grc _obj$D/math.a asin.$O atan2.$O pow.$O sinh.$O
-       rm -f $(O3)
-
-a4: $(O4)
-       $(AR) grc _obj$D/math.a tanh.$O
-       rm -f $(O4)
-
-
-newpkg: clean
-       mkdir -p _obj$D
-       $(AR) grc _obj$D/math.a
-
-$(O1): newpkg
-$(O2): a1
-$(O3): a2
-$(O4): a3
-$(O5): a4
-
-nuke: clean
-       rm -f $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/math.a
-
-packages: _obj$D/math.a
 
-install: packages
-       test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D
-       cp _obj$D/math.a $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/math.a
+TARG=math
+GOFILES=\
+       asin.go\
+       atan.go\
+       atan2.go\
+       const.go\
+       exp.go\
+       fabs.go\
+       floor.go\
+       fmod.go\
+       hypot.go\
+       log.go\
+       pow.go\
+       pow10.go\
+       runtime.go\
+       sin.go\
+       sinh.go\
+       sqrt.go\
+       tan.go\
+       tanh.go\
+
+include $(GOROOT)/src/Make.pkg
index 8973d456ecffcf65a5c6c72e6f612cca5d86ae35..9a7075899ef3772f4cad71855432021fb0242709 100644 (file)
@@ -2,10 +2,10 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package math
+package math_test
 
 import (
-       "math";
+       "math";
        "testing";
 )
 
index 23c9a1069badabc15435d217505aa12a95e9cdc8..38fc365b351b765935126a8e8fb547fd04b2e6f0 100644 (file)
@@ -4,7 +4,6 @@
 
 package math
 
-import "math"
 
 /*
  * asin(arg) and acos(arg) return the arcsin, arccos,
index 4b18f76aaf673bb5fad74c902214ef04f8ef9a38..bc13b3bfaebae460cdac2e4b9d15bc0f90a5a053 100644 (file)
@@ -4,7 +4,6 @@
 
 package math
 
-import "math"
 
 /*
  *     floating-point arctangent
index 72f2117b376e3d5d852ce6b2f0738e33123789b9..efd5cb9268bcc7067e9c3337e77e48c72bbddd90 100644 (file)
@@ -4,7 +4,6 @@
 
 package math
 
-import "math"
 
 // Atan returns the arc tangent of y/x, using
 // the signs of the two to determine the quadrant
index a32c7e1d50c96703890ace2570f660e727d26563..22014daacef51e405afef13cfd33963fe10928fe 100644 (file)
@@ -4,7 +4,6 @@
 
 package math
 
-import "math"
 
 // The original C code, the long comment, and the constants
 // below are from FreeBSD's /usr/src/lib/msun/src/e_exp.c
index 48a1003f044b1ad2cac1bff92d3529ecdbcbca40..1580221ab6717a67552631e055612809310a0d60 100644 (file)
@@ -4,7 +4,6 @@
 
 package math
 
-import "math"
 
 // Floor returns the greatest integer value less than or equal to x.
 func Floor(x float64) float64 {
index 617f5408bbad1d66e1280082adb854125a6b37e4..681c921bb987f0ce3ff7fc821c711d8b22dd6486 100644 (file)
@@ -4,7 +4,6 @@
 
 package math
 
-import "math"
 
 /*
  *     floating-point mod func without infinity or NaN checking
index 603a935acd63bb145ed67eacb8288ffad17e9832..4f9a376062cfae2d9f382613ab9a80d7f7e4ecf1 100644 (file)
@@ -4,7 +4,6 @@
 
 package math
 
-import "math"
 
 // The original C code, the long comment, and the constants
 // below are from FreeBSD's /usr/src/lib/msun/src/e_log.c
@@ -33,19 +32,17 @@ import "math"
 //              = 2s + 2/3 s**3 + 2/5 s**5 + .....,
 //              = 2s + s*R
 //      We use a special Reme algorithm on [0,0.1716] to generate
-//     a polynomial of degree 14 to approximate R The maximum error
+//     a polynomial of degree 14 to approximate R The maximum error
 //     of this polynomial approximation is bounded by 2**-58.45. In
 //     other words,
 //                     2      4      6      8      10      12      14
 //         R(z) ~ L1*s +L2*s +L3*s +L4*s +L5*s  +L6*s  +L7*s
-//     (the values of L1 to L7 are listed in the program)
-//     and
+//     (the values of L1 to L7 are listed in the program) and
 //         |      2          14          |     -58.45
 //         | L1*s +...+L7*s    -  R(z) | <= 2
 //         |                             |
 //     Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
-//     In order to guarantee error in log below 1ulp, we compute log
-//     by
+//     In order to guarantee error in log below 1ulp, we compute log by
 //             log(1+f) = f - s*(f - R)        (if f is not too large)
 //             log(1+f) = f - (hfsq - s*(hfsq+R)).     (better accuracy)
 //
index 920d210b56dc6a90ffe87bac9943c021a3374a2b..93f4fa8e9d6ec490dce55be91f6f94e07af13a9d 100644 (file)
@@ -4,7 +4,6 @@
 
 package math
 
-import "math"
 
 // Pow returns x**y, the base-x exponential of y.
 func Pow(x, y float64) float64 {
index 0c26a767b76edf693eb1e5d32fade4aab25077c2..8f0959ab088ab69c1bfb9aff784d85822f63a191 100644 (file)
@@ -4,7 +4,6 @@
 
 package math
 
-import "math"
 
 func sinus(x float64, quad int) float64 {
        // Coefficients are #3370 from Hart & Cheney (18.80D).
index ef70989fb902630b8e74e425cfa4340050c6c245..1e55f0ba580de2c0723f8c8a1fe7805818b4663a 100644 (file)
@@ -4,7 +4,6 @@
 
 package math
 
-import "math"
 
 /*
  *     Sinh(x) returns the hyperbolic sine of x
index 79384f6481a593782f1e40e2c473af91abc36e59..09bdf6b4c721217ba340821ac2ca564f3e36fddf 100644 (file)
@@ -4,7 +4,6 @@
 
 package math
 
-import "math"
 
 /*
  *     sqrt returns the square root of its floating
index ee6dfbe40ab6d8f48ce21ec9321abce082bf33ea..a8e6b15c9176cf1ae2c83562481853a9d19e78d3 100644 (file)
@@ -4,7 +4,6 @@
 
 package math
 
-import "math"
 
 /*
  *     floating point tangent
index 18d38ae8fece7ca946ef70a0445ff8d83d2c0e1e..20dc5b79d01c0ea8ee1ba75eaefc8b9f56bcb526 100644 (file)
@@ -4,7 +4,6 @@
 
 package math
 
-import "math"
 
 /*
  *     tanh(x) computes the hyperbolic tangent of its floating
index 6350402c2eb73854477c0fc98e50bc5e831f681a..f83250b543a9fb7a04cb97f020e55404a9548468 100644 (file)
@@ -2,59 +2,10 @@
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
-# DO NOT EDIT.  Automatically generated by gobuild.
-# gobuild -m >Makefile
-
-D=
-
 include $(GOROOT)/src/Make.$(GOARCH)
-AR=gopack
-
-default: packages
-
-clean:
-       rm -rf *.[$(OS)] *.a [$(OS)].out _obj
-
-test: packages
-       gotest
-
-coverage: packages
-       gotest
-       6cov -g `pwd` | grep -v '_test\.go:'
-
-%.$O: %.go
-       $(GC) -I_obj $*.go
-
-%.$O: %.c
-       $(CC) $*.c
-
-%.$O: %.s
-       $(AS) $*.s
-
-O1=\
-       once.$O\
-
-
-phases: a1
-_obj$D/once.a: phases
-
-a1: $(O1)
-       $(AR) grc _obj$D/once.a once.$O
-       rm -f $(O1)
-
-
-newpkg: clean
-       mkdir -p _obj$D
-       $(AR) grc _obj$D/once.a
-
-$(O1): newpkg
-$(O2): a1
-
-nuke: clean
-       rm -f $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/once.a
 
-packages: _obj$D/once.a
+TARG=once
+GOFILES=\
+       once.go\
 
-install: packages
-       test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D
-       cp _obj$D/once.a $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/once.a
+include $(GOROOT)/src/Make.pkg
index 9506ff3d7915c0da5add63da86349da6665e2132..749805aead3370eb656c80fadbc5814c697d0101 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package once
+package once_test
 
 import (
        "once";
@@ -14,7 +14,7 @@ func call() {
        ncall++
 }
 
-func TestOnce(t *testing.T) {
+func TestDo(t *testing.T) {
        ncall = 0;
        once.Do(call);
        if ncall != 1 {
index bb2559e8689cc2b04e5bc89b9d2c7e1f99e8318c..323be5edb7f2d37abc1397666ffe7174dacbd929 100644 (file)
@@ -2,92 +2,21 @@
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
-
-# DO NOT EDIT.  Automatically generated by gobuild.
-# gobuild -m dir_${GOOS}_${GOARCH}.go env.go error.go file.go path.go stat_${GOOS}_${GOARCH}.go time.go types.go exec.go proc.go getwd.go sys_${GOOS}.go >Makefile
-
-D=
-
 include $(GOROOT)/src/Make.$(GOARCH)
-AR=gopack
-
-default: packages
-
-clean:
-       rm -rf *.[$(OS)] *.a [$(OS)].out _obj
-
-test: packages
-       gotest
-
-coverage: packages
-       gotest
-       6cov -g $$(pwd) | grep -v '_test\.go:'
-
-%.$O: %.go
-       $(GC) -I_obj $*.go
-
-%.$O: %.c
-       $(CC) $*.c
-
-%.$O: %.s
-       $(AS) $*.s
-
-O1=\
-       error.$O\
-       types.$O\
-
-O2=\
-       proc.$O\
-       stat_$(GOOS)_$(GOARCH).$O\
-       time.$O\
-
-O3=\
-       env.$O\
-       file.$O\
-
-O4=\
-       dir_$(GOOS)_$(GOARCH).$O\
-       exec.$O\
-       getwd.$O\
-       path.$O\
-       sys_$(GOOS).$O\
-
-
-phases: a1 a2 a3 a4
-_obj$D/os.a: phases
-
-a1: $(O1)
-       $(AR) grc _obj$D/os.a error.$O types.$O
-       rm -f $(O1)
-
-a2: $(O2)
-       $(AR) grc _obj$D/os.a proc.$O stat_$(GOOS)_$(GOARCH).$O time.$O
-       rm -f $(O2)
-
-a3: $(O3)
-       $(AR) grc _obj$D/os.a env.$O file.$O
-       rm -f $(O3)
-
-a4: $(O4)
-       $(AR) grc _obj$D/os.a dir_$(GOOS)_$(GOARCH).$O exec.$O getwd.$O path.$O sys_$(GOOS).$O
-       rm -f $(O4)
-
-
-newpkg: clean
-       mkdir -p _obj$D
-       $(AR) grc _obj$D/os.a
-
-$(O1): newpkg
-$(O2): a1
-$(O3): a2
-$(O4): a3
-$(O5): a4
-
-nuke: clean
-       rm -f $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/os.a
-
-packages: _obj$D/os.a
 
-install: packages
-       test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D
-       cp _obj$D/os.a $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/os.a
+TARG=os
+GOFILES=\
+       dir_$(GOOS)_$(GOARCH).go\
+       env.go\
+       error.go\
+       exec.go\
+       file.go\
+       getwd.go\
+       path.go\
+       proc.go\
+       stat_$(GOOS)_$(GOARCH).go\
+       sys_$(GOOS).go\
+       time.go\
+       types.go\
+
+include $(GOROOT)/src/Make.pkg
index 8ae6ba70fbff1a9dbae52375a2a14ea8d3a34420..0131ab1b06eb0184af760416a03dc565ae74f88d 100644 (file)
@@ -5,7 +5,6 @@
 package os
 
 import (
-       "os";
        "syscall";
        "unsafe";
 )
@@ -14,7 +13,11 @@ const (
        blockSize = 4096        // TODO(r): use statfs
 )
 
-// Negative count means read until EOF.
+// Readdirnames reads the contents of the directory associated with file and
+// returns an array of up to count names, in directory order.  Subsequent
+// calls on the same file will yield further names.
+// A negative count means to read until EOF.
+// Readdirnames returns the array and an Error, if any.
 func (file *File) Readdirnames(count int) (names []string, err Error) {
        // If this file has no dirinfo, create one.
        if file.dirinfo == nil {
index 8ae6ba70fbff1a9dbae52375a2a14ea8d3a34420..7701b7d0db882c04e7e0b0884db6ca2d13f2436b 100644 (file)
@@ -5,7 +5,6 @@
 package os
 
 import (
-       "os";
        "syscall";
        "unsafe";
 )
@@ -14,7 +13,6 @@ const (
        blockSize = 4096        // TODO(r): use statfs
 )
 
-// Negative count means read until EOF.
 func (file *File) Readdirnames(count int) (names []string, err Error) {
        // If this file has no dirinfo, create one.
        if file.dirinfo == nil {
index 9b9a1763e866dfcf284f72eb5f7b20974938aefa..0e70f0ba079613f8c89e14b66cdb47fefbf7da40 100644 (file)
@@ -9,7 +9,6 @@
 package os
 
 import (
-       "os";
        "syscall";
        "unsafe";
 )
@@ -27,7 +26,6 @@ func clen(n []byte) int {
        return len(n)
 }
 
-// Negative count means read until EOF.
 func (file *File) Readdirnames(count int) (names []string, err Error) {
        // If this file has no dirinfo, create one.
        if file.dirinfo == nil {
index c0a7ee8b7d610772c407fde98403f928491b9785..8bd29b27c9191b1c21d1aecf076d561c6eafe87a 100644 (file)
@@ -5,7 +5,6 @@
 package os
 
 import (
-       "os";
        "syscall";
        "unsafe";
 )
@@ -23,7 +22,6 @@ func clen(n []byte) int {
        return len(n)
 }
 
-// Negative count means read until EOF.
 func (file *File) Readdirnames(count int) (names []string, err Error) {
        // If this file has no dirinfo, create one.
        if file.dirinfo == nil {
index 5515dae2f5d5a314a25a377d8dc2786d0e257701..b867cb5648890a794a4c06cc147deb52601acd85 100644 (file)
@@ -8,7 +8,6 @@ package os
 
 import (
        "once";
-       "os";
 )
 
 // ENOENV is the Error indicating that an environment variable does not exist.
index d9f7d2a570c5e534c3bfefad8a8fff1838bac46d..3a305243ca7515c2501a6b7aa1ce078f71bb042c 100644 (file)
@@ -5,7 +5,6 @@
 package os
 
 import (
-       "os";
        "syscall";
 )
 
index b2b456429c2c61ac1785ea9f4818d8f637cc56ad..958a8230c6569633b3c73753dd85249b1cdb543f 100644 (file)
@@ -7,7 +7,6 @@
 package os
 
 import (
-       "os";
        "syscall";
 )
 
@@ -257,13 +256,6 @@ func Lstat(name string) (dir *Dir, err Error) {
        return dirFromStat(name, new(Dir), &stat, &stat), nil
 }
 
-// Readdirnames reads the contents of the directory associated with file and
-// returns an array of up to count names, in directory order.  Subsequent
-// calls on the same file will yield further names.
-// A negative count means to read until EOF.
-// Readdirnames returns the array and an Error, if any.
-func (file *File) Readdirnames(count int) (names []string, err Error)
-
 // Readdir reads the contents of the directory associated with file and
 // returns an array of up to count Dir structures, as would be returned
 // by Stat, in directory order.  Subsequent calls on the same file will yield further Dirs.
index 5b1b4e2e285c742091bfe17909603d8303e48172..5aeeaa0c3a3028fb062d8be43f2509f2224c4982 100644 (file)
@@ -5,7 +5,6 @@
 package os
 
 import (
-       "os";
        "syscall"
 )
 
index a10a6af72e9771b493f336905cc7c4a974c93b61..84c4d15a017b6f08a198d6868786744347166353 100644 (file)
@@ -2,13 +2,13 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package os
+package os_test
 
 import (
        "bytes";
        "fmt";
        "io";
-       "os";
+       "os";
        "strings";
        "testing";
 )
index 8499ec9600d7027d785e7a91fadf147e2519eeae..a1718b5a3ddfabb354cd389417001dc387367b3b 100644 (file)
@@ -4,7 +4,6 @@
 
 package os
 
-import "os"
 
 // MkdirAll creates a directory named path,
 // along with any necessary parents, and returns nil,
index 357d6882f31df56ccfe966e3dac74610c0c57c3d..2790d98931d4c1eb8118cc0b78f155b6d0668e40 100644 (file)
@@ -2,10 +2,10 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package os
+package os_test
 
 import (
-       "os";
+       "os";
        "testing";
 )
 
index 38380c1e3aa2108eec954a8b89627276e356c0a2..39d5515bac8c8134bf89a0f09bf4d5229c9230fe 100644 (file)
@@ -8,7 +8,6 @@ package os
 
 import (
        "syscall";
-       "os";
        "unsafe";
 )
 
index a6d7b78d152ed38aaa169523cd509398921d761b..cc6e549666bc7430433709a87a3c209eb5538601 100644 (file)
@@ -6,8 +6,7 @@
 
 package os
 
-import syscall "syscall"
-import os "os"
+import "syscall"
 
 func isSymlink(stat *syscall.Stat_t) bool {
        return stat.Mode & syscall.S_IFMT == syscall.S_IFLNK
index 1771ca160bec4578ff50ca576da164cb35f65af1..c6f031a2446b6b0b5b63c2c61ad51f0a803dd53d 100644 (file)
@@ -6,8 +6,7 @@
 
 package os
 
-import syscall "syscall"
-import os "os"
+import "syscall"
 
 func isSymlink(stat *syscall.Stat_t) bool {
        return stat.Mode & syscall.S_IFMT == syscall.S_IFLNK
index 13ee942c979b70ba089fad74235f711bc28bf662..d08fabcc605d2a0f9b014555c56c4486419ec1c8 100644 (file)
 
 package os
 
-import (
-       "os";
-       "syscall";
-)
+import "syscall"
 
 func isSymlink(stat *syscall.Stat_t) bool {
        return stat.Mode & syscall.S_IFMT == syscall.S_IFLNK
index 9b301817846c71ff793e99e510f5af528681b0c9..f4c300b2c810c0ce57e922f48a1c3de689539b98 100644 (file)
@@ -6,8 +6,7 @@
 
 package os
 
-import syscall "syscall"
-import os "os"
+import "syscall"
 
 func isSymlink(stat *syscall.Stat_t) bool {
        return stat.Mode & syscall.S_IFMT == syscall.S_IFLNK
index 731709dfccb2677000db9ed16e5406cce7f4d52c..fb57f1733bdfaa3c4d6c28983e8a8bfec12799d3 100644 (file)
@@ -6,10 +6,7 @@
 
 package os
 
-import (
-       "os";
-       "syscall";
-)
+import "syscall"
 
 func Hostname() (name string, err Error) {
        var errno int;
index 6ff4e014fb0c850f164f30e6e5260e7cc2181d5e..12a99dff329c3ecf15b43beaea8b9d9e868e3b00 100644 (file)
@@ -6,7 +6,6 @@
 
 package os
 
-import "os"
 
 // Hostname returns the host name reported by the kernel.
 func Hostname() (name string, err Error) {
index e1022066fde6eb5d34aecdcb13d1ff61dc178220..d0ba6e1fa564665a9d1ea512d11daf5be2f2bc90 100644 (file)
@@ -4,10 +4,7 @@
 
 package os
 
-import (
-       "os";
-       "syscall"
-)
+import "syscall"
 
 
 // Time returns the current time, in whole seconds and
index 32c35090326acf9b84a697e847b29a3a3a5dcd11..9e9ea3ad6e230341fda307c714ccdfe86e1363da 100644 (file)
@@ -2,77 +2,12 @@
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
-
-# DO NOT EDIT.  Automatically generated by gobuild.
-# gobuild -m >Makefile
-
-D=
-
 include $(GOROOT)/src/Make.$(GOARCH)
-AR=gopack
-
-default: packages
-
-clean:
-       rm -rf *.[$(OS)] *.a [$(OS)].out _obj
-
-test: packages
-       gotest
-
-coverage: packages
-       gotest
-       6cov -g $$(pwd) | grep -v '_test\.go:'
-
-%.$O: %.go
-       $(GC) -I_obj $*.go
-
-%.$O: %.c
-       $(CC) $*.c
-
-%.$O: %.s
-       $(AS) $*.s
-
-O1=\
-       type.$O\
-
-O2=\
-       value.$O\
-
-O3=\
-       deepequal.$O\
-       tostring.$O\
-
-
-phases: a1 a2 a3
-_obj$D/reflect.a: phases
-
-a1: $(O1)
-       $(AR) grc _obj$D/reflect.a type.$O
-       rm -f $(O1)
-
-a2: $(O2)
-       $(AR) grc _obj$D/reflect.a value.$O
-       rm -f $(O2)
-
-a3: $(O3)
-       $(AR) grc _obj$D/reflect.a deepequal.$O tostring.$O
-       rm -f $(O3)
-
-
-newpkg: clean
-       mkdir -p _obj$D
-       $(AR) grc _obj$D/reflect.a
-
-$(O1): newpkg
-$(O2): a1
-$(O3): a2
-$(O4): a3
-
-nuke: clean
-       rm -f $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/reflect.a
 
-packages: _obj$D/reflect.a
+TARG=reflect
+GOFILES=\
+       deepequal.go\
+       type.go\
+       value.go\
 
-install: packages
-       test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D
-       cp _obj$D/reflect.a $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/reflect.a
+include $(GOROOT)/src/Make.pkg
index 297c95e39673697f7f44202d8089053ddc6b5e09..6aa54e01ce13e33293c450219a100cd6f599a816 100644 (file)
@@ -2,12 +2,12 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package reflect
+package reflect_test
 
 import (
        "io";
        "os";
-       "reflect";
+       "reflect";
        "testing";
        "unsafe";
 )
@@ -50,14 +50,14 @@ var typeTests = []pair {
        pair { struct { x float64 }{}, "float64" },
        pair { struct { x int8 }{}, "int8" },
        pair { struct { x (**int8) }{}, "**int8" },
-       pair { struct { x (**reflect.integer) }{}, "**reflect.integer" },
+       pair { struct { x (**integer) }{}, "**reflect_test.integer" },
        pair { struct { x ([32]int32) }{}, "[32]int32" },
        pair { struct { x ([]int8) }{}, "[]int8" },
        pair { struct { x (map[string]int32) }{}, "map[string] int32" },
        pair { struct { x (chan<-string) }{}, "chan<- string" },
        pair { struct { x struct {c chan *int32; d float32} }{}, "struct { c chan *int32; d float32 }" },
        pair { struct { x (func(a int8, b int32)) }{}, "func(int8, int32)" },
-       pair { struct { x struct {c func(chan *reflect.integer, *int8)} }{}, "struct { c func(chan *reflect.integer, *int8) }" },
+       pair { struct { x struct {c func(chan *integer, *int8)} }{}, "struct { c func(chan *reflect_test.integer, *int8) }" },
        pair { struct { x struct {a int8; b int32} }{}, "struct { a int8; b int32 }" },
        pair { struct { x struct {a int8; b int8; c int32} }{}, "struct { a int8; b int8; c int32 }" },
        pair { struct { x struct {a int8; b int8; c int8; d int32} }{}, "struct { a int8; b int8; c int8; d int32 }" },
@@ -85,12 +85,12 @@ var valueTests = []pair {
        pair { (*int8)(nil), "*int8(0)" },
        pair { (**int8)(nil), "**int8(0)" },
        pair { ([5]int32){}, "[5]int32{0, 0, 0, 0, 0}" },
-       pair { (**reflect.integer)(nil), "**reflect.integer(0)" },
+       pair { (**integer)(nil), "**reflect_test.integer(0)" },
        pair { (map[string]int32)(nil), "map[string] int32{<can't iterate on maps>}" },
        pair { (chan<-string)(nil), "chan<- string" },
        pair { (struct {c chan *int32; d float32}){}, "struct { c chan *int32; d float32 }{chan *int32, 0}" },
        pair { (func(a int8, b int32))(nil), "func(int8, int32)(0)" },
-       pair { (struct {c func(chan *reflect.integer, *int8)}){}, "struct { c func(chan *reflect.integer, *int8) }{func(chan *reflect.integer, *int8)(0)}" },
+       pair { (struct {c func(chan *integer, *int8)}){}, "struct { c func(chan *reflect_test.integer, *int8) }{func(chan *reflect_test.integer, *int8)(0)}" },
        pair { (struct {a int8; b int32}){}, "struct { a int8; b int32 }{0, 0}" },
        pair { (struct {a int8; b int8; c int32}){}, "struct { a int8; b int8; c int32 }{0, 0, 0}" },
 }
@@ -112,35 +112,35 @@ func TestValue(t *testing.T) {
        for i, tt := range valueTests {
                v := NewValue(tt.i);
                switch v := v.(type) {
-               case *reflect.IntValue:
+               case *IntValue:
                        v.Set(132);
-               case *reflect.Int8Value:
+               case *Int8Value:
                        v.Set(8);
-               case *reflect.Int16Value:
+               case *Int16Value:
                        v.Set(16);
-               case *reflect.Int32Value:
+               case *Int32Value:
                        v.Set(32);
-               case *reflect.Int64Value:
+               case *Int64Value:
                        v.Set(64);
-               case *reflect.UintValue:
+               case *UintValue:
                        v.Set(132);
-               case *reflect.Uint8Value:
+               case *Uint8Value:
                        v.Set(8);
-               case *reflect.Uint16Value:
+               case *Uint16Value:
                        v.Set(16);
-               case *reflect.Uint32Value:
+               case *Uint32Value:
                        v.Set(32);
-               case *reflect.Uint64Value:
+               case *Uint64Value:
                        v.Set(64);
-               case *reflect.FloatValue:
+               case *FloatValue:
                        v.Set(3200.0);
-               case *reflect.Float32Value:
+               case *Float32Value:
                        v.Set(32.1);
-               case *reflect.Float64Value:
+               case *Float64Value:
                        v.Set(64.2);
-               case *reflect.StringValue:
+               case *StringValue:
                        v.Set("stringy cheese");
-               case *reflect.BoolValue:
+               case *BoolValue:
                        v.Set(true);
                }
                s := valueToString(v);
@@ -157,8 +157,8 @@ var valueToStringTests = []pair {
        pair { 123.4, "123.4" },
        pair { byte(123), "123" },
        pair { "abc", "abc" },
-       pair { T{123, 456.75, "hello", &_i}, "reflect.T{123, 456.75, hello, *int(&7)}" },
-       pair { new(chan *T), "*chan *reflect.T(&chan *reflect.T)" },
+       pair { T{123, 456.75, "hello", &_i}, "reflect_test.T{123, 456.75, hello, *int(&7)}" },
+       pair { new(chan *T), "*chan *reflect_test.T(&chan *reflect_test.T)" },
        pair { [10]int{1,2,3,4,5,6,7,8,9,10}, "[10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}" },
        pair { &[10]int{1,2,3,4,5,6,7,8,9,10}, "*[10]int(&[10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})" },
        pair { []int{1,2,3,4,5,6,7,8,9,10}, "[]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}" },
@@ -771,7 +771,7 @@ func (p Point) Dist(scale int) int {
 func TestMethod(t *testing.T) {
        // Non-curried method of type.
        p := Point{3, 4};
-       i := reflect.Typeof(p).Method(0).Func.Call([]Value{NewValue(p), NewValue(10)})[0].(*IntValue).Get();
+       i := Typeof(p).Method(0).Func.Call([]Value{NewValue(p), NewValue(10)})[0].(*IntValue).Get();
        if i != 250 {
                t.Errorf("Type Method returned %d; want 250", i);
        }
@@ -812,7 +812,7 @@ func TestInterfaceSet(t *testing.T) {
        if q := s.P.(*Point); q != p {
                t.Errorf("i: have %p want %p", q, p);
        }
-       
+
        i := pv.Method(0).Call([]Value{NewValue(10)})[0].(*IntValue).Get();
        if i != 250 {
                t.Errorf("Interface Method returned %d; want 250", i);
@@ -907,7 +907,7 @@ func TestFieldByIndex(t *testing.T) {
                }
 
                if test.value != 0 {
-                       v := reflect.NewValue(test.s).(*reflect.StructValue).FieldByIndex(test.index);
+                       v := NewValue(test.s).(*StructValue).FieldByIndex(test.index);
                        if v != nil {
                                if x, ok := v.Interface().(int); ok {
                                        if x != test.value {
@@ -945,9 +945,9 @@ func TestFieldByName(t *testing.T) {
                } else if len(test.index) > 0 {
                        t.Errorf("%s.%s not found", s.Name(), test.name);
                }
-               
+
                if test.value != 0 {
-                       v := reflect.NewValue(test.s).(*reflect.StructValue).FieldByName(test.name);
+                       v := NewValue(test.s).(*StructValue).FieldByName(test.name);
                        if v != nil {
                                if x, ok := v.Interface().(int); ok {
                                        if x != test.value {
index e93513e8d9c2a86be8ac5536b53e00772daa4627..86da3c6ee941c675e0e48f607809dda5f999888e 100644 (file)
@@ -6,7 +6,6 @@
 
 package reflect
 
-import "reflect"
 
 // During deepValueEqual, must keep track of checks that are
 // in progress.  The comparison algorithm assumes that all
similarity index 94%
rename from src/pkg/reflect/tostring.go
rename to src/pkg/reflect/tostring_test.go
index b9ada7b50ec2f664d9a5de0938472c5191e4c614..e2f7dbf75f25ce4341158e7c91e022854775463c 100644 (file)
@@ -2,15 +2,14 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// Reflection library.
 // Formatting of reflection types and values for debugging.
 // Not defined as methods so they do not need to be linked into most binaries;
 // the functions are not used by the library itself, only in tests.
 
-package reflect
+package reflect_test
 
 import (
-       "reflect";
+       "reflect";
        "strconv";
 )
 
@@ -113,7 +112,7 @@ func valueToString(val Value) string {
                v := val;
                return typ.String() + "(" + strconv.Itoa64(int64(v.Get())) + ")";
        default:
-               panicln("reflect.valueToString: can't print type ", typ.String());
+               panicln("valueToString: can't print type ", typ.String());
        }
-       return "reflect.valueToString: can't happen";
+       return "valueToString: can't happen";
 }
index 9820864f030d58ac0e3e0ba350da4ea289fdb07f..4bd2fc1214659a16590ea26f192916063bf1216b 100644 (file)
@@ -226,11 +226,6 @@ type StructType struct {
  * The compiler does not know about the data structures and methods below.
  */
 
-type Type interface
-type addr unsafe.Pointer
-type FuncValue struct
-func newFuncValue(typ Type, addr addr, canSet bool) *FuncValue
-
 // Method represents a single method.
 type Method struct {
        PkgPath string;         // empty for uppercase Name
@@ -281,8 +276,6 @@ type Type interface {
        uncommon() *uncommonType;
 }
 
-func toType(i interface{}) Type
-
 func (t *uncommonType) uncommon() *uncommonType {
        return t;
 }
index f1ea106557483f933af3adad7e9007e2424f4d6f..e2df30b799e945d39f20ba33a7b8c17b813d47ae 100644 (file)
@@ -5,14 +5,13 @@
 package reflect
 
 import (
-       "reflect";
        "runtime";
        "unsafe";
 )
 
 const ptrSize = uintptr(unsafe.Sizeof((*byte)(nil)))
-
 const cannotSet = "cannot set value obtained via unexported struct field"
+type addr unsafe.Pointer
 
 // TODO: This will have to go away when
 // the new gc goes in.
@@ -72,8 +71,6 @@ type Value interface {
        getAddr()       addr;
 }
 
-func MakeZero(typ Type) Value
-
 type value struct {
        typ Type;
        addr addr;
@@ -92,11 +89,6 @@ func (v *value) getAddr() addr {
        return v.addr;
 }
 
-func (v *value) Method(i int) *FuncValue
-
-type InterfaceValue struct
-type StructValue struct
-
 func (v *value) Interface() interface{} {
        if typ, ok := v.typ.(*InterfaceType); ok {
                // There are two different representations of interface values,
@@ -117,9 +109,6 @@ func (v *value) CanSet() bool {
        return v.canSet;
 }
 
-func newValue(typ Type, addr addr, canSet bool) Value
-func NewValue(i interface{}) Value
-
 /*
  * basic types
  */
@@ -420,7 +409,6 @@ type UnsafePointerValue struct {
 // Get returns the underlying uintptr value.
 // Get returns uintptr, not unsafe.Pointer, so that
 // programs that do not import "unsafe" cannot
-// obtain a value of unsafe.Pointer type from "reflect".
 func (v *UnsafePointerValue) Get() uintptr {
        return uintptr(*(*unsafe.Pointer)(v.addr));
 }
index f2952184419ea99dedbceb8c41dad803b4e873f1..af5c5e1108e8f7f86729dc0625a780047c1fb24d 100644 (file)
@@ -2,79 +2,15 @@
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
-
-# DO NOT EDIT.  Automatically generated by gobuild.
-# gobuild -m >Makefile
-
-D=
-
 include $(GOROOT)/src/Make.$(GOARCH)
-AR=gopack
-
-default: packages
-
-clean:
-       rm -rf *.[$(OS)] *.a [$(OS)].out _obj
-
-test: packages
-       gotest
-
-coverage: packages
-       gotest
-       6cov -g $$(pwd) | grep -v '_test\.go:'
-
-%.$O: %.go
-       $(GC) -I_obj $*.go
-
-%.$O: %.c
-       $(CC) $*.c
-
-%.$O: %.s
-       $(AS) $*.s
-
-O1=\
-       decimal.$O\
-       itoa.$O\
-       quote.$O\
-
-O2=\
-       atoi.$O\
-       ftoa.$O\
-
-O3=\
-       atof.$O\
-
-
-phases: a1 a2 a3
-_obj$D/strconv.a: phases
-
-a1: $(O1)
-       $(AR) grc _obj$D/strconv.a decimal.$O itoa.$O quote.$O
-       rm -f $(O1)
-
-a2: $(O2)
-       $(AR) grc _obj$D/strconv.a atoi.$O ftoa.$O
-       rm -f $(O2)
-
-a3: $(O3)
-       $(AR) grc _obj$D/strconv.a atof.$O
-       rm -f $(O3)
-
-
-newpkg: clean
-       mkdir -p _obj$D
-       $(AR) grc _obj$D/strconv.a
-
-$(O1): newpkg
-$(O2): a1
-$(O3): a2
-$(O4): a3
-
-nuke: clean
-       rm -f $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/strconv.a
 
-packages: _obj$D/strconv.a
+TARG=strconv
+GOFILES=\
+       atof.go\
+       atoi.go\
+       decimal.go\
+       ftoa.go\
+       itoa.go\
+       quote.go\
 
-install: packages
-       test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D
-       cp _obj$D/strconv.a $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/strconv.a
+include $(GOROOT)/src/Make.pkg
index 6d6ec562ce9e30fc2bd9b5766f0708b3c8c2fbd2..13795580940fddac86961073c660a3157033bc4a 100644 (file)
@@ -15,7 +15,6 @@ package strconv
 import (
        "math";
        "os";
-       "strconv";
 )
 
 var optimize = true    // can change for testing
index ecccab79b075dd3a78e3d2fef14eebc22f2432f1..e78244ea0acbdef68fae1a9b9550e6450f1bbb04 100644 (file)
@@ -2,13 +2,14 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package strconv
+package strconv_test
+
 import (
        "fmt";
        "os";
        "reflect";
-       "strconv";
-       "testing"
+       "strconv";
+       "testing";
 )
 
 type atofTest struct {
@@ -104,36 +105,35 @@ func init() {
 }
 
 func testAtof(t *testing.T, opt bool) {
-       oldopt := strconv.optimize;
-       strconv.optimize = opt;
+       oldopt := SetOptimize(opt);
        for i := 0; i < len(atoftests); i++ {
                test := &atoftests[i];
-               out, err := strconv.Atof64(test.in);
-               outs := strconv.Ftoa64(out, 'g', -1);
+               out, err := Atof64(test.in);
+               outs := Ftoa64(out, 'g', -1);
                if outs != test.out || !reflect.DeepEqual(err, test.err) {
-                       t.Errorf("strconv.Atof64(%v) = %v, %v want %v, %v\n",
+                       t.Errorf("Atof64(%v) = %v, %v want %v, %v\n",
                                test.in, out, err, test.out, test.err);
                }
 
                if float64(float32(out)) == out {
-                       out32, err := strconv.Atof32(test.in);
-                       outs := strconv.Ftoa32(out32, 'g', -1);
+                       out32, err := Atof32(test.in);
+                       outs := Ftoa32(out32, 'g', -1);
                        if outs != test.out || !reflect.DeepEqual(err, test.err) {
-                               t.Errorf("strconv.Atof32(%v) = %v, %v want %v, %v  # %v\n",
+                               t.Errorf("Atof32(%v) = %v, %v want %v, %v  # %v\n",
                                        test.in, out32, err, test.out, test.err, out);
                        }
                }
 
                if FloatSize == 64 || float64(float32(out)) == out {
-                       outf, err := strconv.Atof(test.in);
-                       outs := strconv.Ftoa(outf, 'g', -1);
+                       outf, err := Atof(test.in);
+                       outs := Ftoa(outf, 'g', -1);
                        if outs != test.out || !reflect.DeepEqual(err, test.err) {
-                               t.Errorf("strconv.Ftoa(%v) = %v, %v want %v, %v  # %v\n",
+                               t.Errorf("Ftoa(%v) = %v, %v want %v, %v  # %v\n",
                                        test.in, outf, err, test.out, test.err, out);
                        }
                }
        }
-       strconv.optimize = oldopt;
+       SetOptimize(oldopt);
 }
 
 func TestAtof(t *testing.T) {
index cc9688bb0520be561742671218fa9a48316c001d..d86d0f88b188e3cf02990b0033d6838dbe36c5db 100644 (file)
@@ -3,10 +3,8 @@
 // license that can be found in the LICENSE file.
 
 package strconv
-import (
-       "os";
-       "strconv"
-)
+
+import "os"
 
 type NumError struct {
        Num string;
@@ -25,7 +23,7 @@ func computeIntsize() uint {
        }
        return siz
 }
-var intsize = computeIntsize();
+var IntSize = computeIntsize();
 
 // Return the first number n such that n*base >= 1<<64.
 func cutoff64(base int) uint64 {
@@ -189,9 +187,9 @@ func Atoi(s string) (i int, err os.Error) {
        i = int(i1);
        if int64(i) != i1 {
                if i1 < 0 {
-                       return -1<<(intsize-1), &NumError{s, os.ERANGE}
+                       return -1<<(IntSize-1), &NumError{s, os.ERANGE}
                }
-               return 1<<(intsize-1) - 1, &NumError{s, os.ERANGE}
+               return 1<<(IntSize-1) - 1, &NumError{s, os.ERANGE}
        }
        return i, nil
 }
index 54630ae62b84d6c643e7c31270540aa3d00f3e4b..ab46e50f4000eaaa7745ee0ca9ab2699fa229164 100644 (file)
@@ -2,14 +2,14 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package strconv
+package strconv_test
 
 import (
        "fmt";
        "os";
        "reflect";
-       "strconv";
-       "testing"
+       "strconv";
+       "testing";
 )
 
 type atoui64Test struct {
@@ -151,9 +151,9 @@ func init() {
 func TestAtoui64(t *testing.T) {
        for i := range atoui64tests {
                test := &atoui64tests[i];
-               out, err := strconv.Atoui64(test.in);
+               out, err := Atoui64(test.in);
                if test.out != out || !reflect.DeepEqual(test.err, err) {
-                       t.Errorf("strconv.Atoui64(%q) = %v, %v want %v, %v\n",
+                       t.Errorf("Atoui64(%q) = %v, %v want %v, %v\n",
                                test.in, out, err, test.out, test.err);
                }
        }
@@ -162,31 +162,31 @@ func TestAtoui64(t *testing.T) {
 func TestAtoi64(t *testing.T) {
        for i := range atoi64tests {
                test := &atoi64tests[i];
-               out, err := strconv.Atoi64(test.in);
+               out, err := Atoi64(test.in);
                if test.out != out || !reflect.DeepEqual(test.err, err) {
-                       t.Errorf("strconv.Atoi64(%q) = %v, %v want %v, %v\n",
+                       t.Errorf("Atoi64(%q) = %v, %v want %v, %v\n",
                                test.in, out, err, test.out, test.err);
                }
        }
 }
 
 func TestAtoui(t *testing.T) {
-       switch intsize {
+       switch IntSize {
        case 32:
                for i := range atoui32tests {
                        test := &atoui32tests[i];
-                       out, err := strconv.Atoui(test.in);
+                       out, err := Atoui(test.in);
                        if test.out != uint32(out) || !reflect.DeepEqual(test.err, err) {
-                               t.Errorf("strconv.Atoui(%q) = %v, %v want %v, %v\n",
+                               t.Errorf("Atoui(%q) = %v, %v want %v, %v\n",
                                        test.in, out, err, test.out, test.err);
                        }
                }
        case 64:
                for i := range atoui64tests {
                        test := &atoui64tests[i];
-                       out, err := strconv.Atoui(test.in);
+                       out, err := Atoui(test.in);
                        if test.out != uint64(out) || !reflect.DeepEqual(test.err, err) {
-                               t.Errorf("strconv.Atoui(%q) = %v, %v want %v, %v\n",
+                               t.Errorf("Atoui(%q) = %v, %v want %v, %v\n",
                                        test.in, out, err, test.out, test.err);
                        }
                }
@@ -194,22 +194,22 @@ func TestAtoui(t *testing.T) {
 }
 
 func TestAtoi(t *testing.T) {
-       switch intsize {
+       switch IntSize {
        case 32:
                for i := range atoi32tests {
                        test := &atoi32tests[i];
-                       out, err := strconv.Atoi(test.in);
+                       out, err := Atoi(test.in);
                        if test.out != int32(out) || !reflect.DeepEqual(test.err, err) {
-                               t.Errorf("strconv.Atoi(%q) = %v, %v want %v, %v\n",
+                               t.Errorf("Atoi(%q) = %v, %v want %v, %v\n",
                                        test.in, out, err, test.out, test.err);
                        }
                }
        case 64:
                for i := range atoi64tests {
                        test := &atoi64tests[i];
-                       out, err := strconv.Atoi(test.in);
+                       out, err := Atoi(test.in);
                        if test.out != int64(out) || !reflect.DeepEqual(test.err, err) {
-                               t.Errorf("strconv.Atoi(%q) = %v, %v want %v, %v\n",
+                               t.Errorf("Atoi(%q) = %v, %v want %v, %v\n",
                                        test.in, out, err, test.out, test.err);
                        }
                }
index bf559b1936afafb391acc0a56f9c6bbd2882fd86..6772c096156a4d3d87818b743e7afca19685b25a 100644 (file)
@@ -20,16 +20,6 @@ type decimal struct {
        nd int; // number of digits used
        dp int; // decimal point
 };
-func (a *decimal) String() string;
-func (a *decimal) Assign(v uint64);
-func (a *decimal) Shift(k int) *decimal;
-func (a *decimal) Round(nd int) *decimal;
-func (a *decimal) RoundUp(nd int) *decimal;
-func (a *decimal) RoundDown(nd int) *decimal;
-func (a *decimal) RoundedInteger() uint64;
-
-
-func digitZero(dst []byte) int;
 
 func (a *decimal) String() string {
        n := 10 + a.nd;
index bc82861bdd7d5d4c98197f1facb80f8deb008a72..1498deaec8c8f0d3b9672784363922d26295defb 100644 (file)
@@ -2,11 +2,11 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package strconv
+package strconv_test
 
 import (
        "fmt";
-       "strconv";
+       "strconv";
        "testing";
 )
 
@@ -33,7 +33,7 @@ func TestDecimalShift(t *testing.T) {
        ok := true;
        for i := 0; i < len(shifttests); i++ {
                test := &shifttests[i];
-               s := strconv.newDecimal(test.i).Shift(test.shift).String();
+               s := NewDecimal(test.i).Shift(test.shift).String();
                if s != test.out {
                        t.Errorf("Decimal %v << %v = %v, want %v\n",
                                test.i, test.shift, s, test.out);
@@ -69,17 +69,17 @@ var roundtests = []roundTest {
 func TestDecimalRound(t *testing.T) {
        for i := 0; i < len(roundtests); i++ {
                test := &roundtests[i];
-               s := strconv.newDecimal(test.i).RoundDown(test.nd).String();
+               s := NewDecimal(test.i).RoundDown(test.nd).String();
                if s != test.down {
                        t.Errorf("Decimal %v RoundDown %d = %v, want %v\n",
                                test.i, test.nd, s, test.down);
                }
-               s = strconv.newDecimal(test.i).Round(test.nd).String();
+               s = NewDecimal(test.i).Round(test.nd).String();
                if s != test.round {
                        t.Errorf("Decimal %v Round %d = %v, want %v\n",
                                test.i, test.nd, s, test.down);
                }
-               s = strconv.newDecimal(test.i).RoundUp(test.nd).String();
+               s = NewDecimal(test.i).RoundUp(test.nd).String();
                if s != test.up {
                        t.Errorf("Decimal %v RoundUp %d = %v, want %v\n",
                                test.i, test.nd, s, test.up);
@@ -109,11 +109,10 @@ var roundinttests = []roundIntTest {
 func TestDecimalRoundedInteger(t *testing.T) {
        for i := 0; i < len(roundinttests); i++ {
                test := roundinttests[i];
-               // TODO: should be able to use int := here.
-               int1 := strconv.newDecimal(test.i).Shift(test.shift).RoundedInteger();
-               if int1 != test.int {
+               int := NewDecimal(test.i).Shift(test.shift).RoundedInteger();
+               if int != test.int {
                        t.Errorf("Decimal %v >> %v RoundedInteger = %v, want %v\n",
-                               test.i, test.shift, int1, test.int);
+                               test.i, test.shift, int, test.int);
                }
        }
 }
index 20e158cec90eec016d35b04ba69dc2e35ae578a1..0890b0fad2cc67380c499a6ca6dcb69572665660 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package strconv
+package strconv_test
 import (
        "bufio";
        "fmt";
@@ -144,6 +144,5 @@ func TestFp(t *testing.T) {
                        t.Error("testfp.txt:", lineno, ": ", a[0], " ", a[1], " ", a[2], " (", v, ") ",
                                "want ", a[3], " got ", s);
                }
-//else print("testfp.txt:", lineno, ": worked! ", s, "\n");
        }
 }
index b171151758d5c9b9faeaf56a3526e6a9adc3186a..b5835c7c8576c7db597073d459ab40a4c4b84569 100644 (file)
 
 package strconv
 
-import (
-       "math";
-       "strconv";
-)
+import "math"
 
 // TODO: move elsewhere?
 type floatInfo struct {
@@ -24,13 +21,6 @@ type floatInfo struct {
 var float32info = floatInfo{ 23, 8, -127 }
 var float64info = floatInfo{ 52, 11, -1023 }
 
-func fmtB(neg bool, mant uint64, exp int, flt *floatInfo) string
-func fmtE(neg bool, d *decimal, prec int) string
-func fmtF(neg bool, d *decimal, prec int) string
-func genericFtoa(bits uint64, fmt byte, prec int, flt *floatInfo) string
-func max(a, b int) int
-func roundShortest(d *decimal, mant uint64, exp int, flt *floatInfo)
-
 func floatsize() int {
        // Figure out whether float is float32 or float64.
        // 1e-35 is representable in both, but 1e-70
index 0f0baa51454ade32757480726f7ceff3a0e895fb..44402439ca188594c86e8591a53a177665d7ad62 100644 (file)
@@ -2,12 +2,12 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package strconv
+package strconv_test
 
 import (
        "math";
-       "strconv";
-       "testing"
+       "strconv";
+       "testing";
 )
 
 type ftoaTest struct {
@@ -100,17 +100,17 @@ var ftoatests = []ftoaTest {
 }
 
 func TestFtoa(t *testing.T) {
-       if strconv.FloatSize != 32 {
-               panic("floatsize: ", strconv.FloatSize);
+       if FloatSize != 32 {
+               panic("floatsize: ", FloatSize);
        }
        for i := 0; i < len(ftoatests); i++ {
                test := &ftoatests[i];
-               s := strconv.Ftoa64(test.f, test.fmt, test.prec);
+               s := Ftoa64(test.f, test.fmt, test.prec);
                if s != test.s {
                        t.Error("test", test.f, string(test.fmt), test.prec, "want", test.s, "got", s);
                }
                if float64(float32(test.f)) == test.f && test.fmt != 'b' {
-                       s := strconv.Ftoa32(float32(test.f), test.fmt, test.prec);
+                       s := Ftoa32(float32(test.f), test.fmt, test.prec);
                        if s != test.s {
                                t.Error("test32", test.f, string(test.fmt), test.prec, "want", test.s, "got", s);
                        }
diff --git a/src/pkg/strconv/internal_test.go b/src/pkg/strconv/internal_test.go
new file mode 100644 (file)
index 0000000..8ec75db
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// export access to strconv internals for tests
+
+package strconv
+
+func NewDecimal(i uint64) *decimal {
+       return newDecimal(i);
+}
+
+func SetOptimize(b bool) bool {
+       old := optimize;
+       optimize = b;
+       return old;
+}
+
index 998c306239e1025a9d48849764d715eb0b09044f..793ece60ec46af08f007fd19ddcd8caa6406cd53 100644 (file)
@@ -2,12 +2,12 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package strconv
+package strconv_test
 
 import (
        "fmt";
        "os";
-       "strconv";
+       "strconv";
        "testing";
 )
 
@@ -61,62 +61,62 @@ var itob64tests = []itob64Test {
 
 func TestItoa(t *testing.T) {
        for i, test := range itob64tests {
-               s := strconv.Itob64(test.in, test.base);
+               s := Itob64(test.in, test.base);
                if s != test.out {
-                       t.Errorf("strconv.Itob64(%v, %v) = %v want %v\n",
+                       t.Errorf("Itob64(%v, %v) = %v want %v\n",
                                test.in, test.base, s, test.out);
                }
 
                if test.in >= 0 {
-                       s := strconv.Uitob64(uint64(test.in), test.base);
+                       s := Uitob64(uint64(test.in), test.base);
                        if s != test.out {
-                               t.Errorf("strconv.Uitob64(%v, %v) = %v want %v\n",
+                               t.Errorf("Uitob64(%v, %v) = %v want %v\n",
                                        test.in, test.base, s, test.out);
                        }
                }
 
                if int64(int(test.in)) == test.in {
-                       s := strconv.Itob(int(test.in), test.base);
+                       s := Itob(int(test.in), test.base);
                        if s != test.out {
-                               t.Errorf("strconv.Itob(%v, %v) = %v want %v\n",
+                               t.Errorf("Itob(%v, %v) = %v want %v\n",
                                        test.in, test.base, s, test.out);
                        }
 
                        if test.in >= 0  {
-                               s := strconv.Uitob(uint(test.in), test.base);
+                               s := Uitob(uint(test.in), test.base);
                                if s != test.out {
-                                       t.Errorf("strconv.Uitob(%v, %v) = %v want %v\n",
+                                       t.Errorf("Uitob(%v, %v) = %v want %v\n",
                                                test.in, test.base, s, test.out);
                                }
                        }
                }
 
                if test.base == 10 {
-                       s := strconv.Itoa64(test.in);
+                       s := Itoa64(test.in);
                        if s != test.out {
-                               t.Errorf("strconv.Itoa64(%v) = %v want %v\n",
+                               t.Errorf("Itoa64(%v) = %v want %v\n",
                                        test.in, s, test.out);
                        }
 
                        if test.in >= 0 {
-                               s := strconv.Uitob64(uint64(test.in), test.base);
+                               s := Uitob64(uint64(test.in), test.base);
                                if s != test.out {
-                                       t.Errorf("strconv.Uitob64(%v, %v) = %v want %v\n",
+                                       t.Errorf("Uitob64(%v, %v) = %v want %v\n",
                                                test.in, test.base, s, test.out);
                                }
                        }
 
                        if int64(int(test.in)) == test.in {
-                               s := strconv.Itoa(int(test.in));
+                               s := Itoa(int(test.in));
                                if s != test.out {
-                                       t.Errorf("strconv.Itoa(%v) = %v want %v\n",
+                                       t.Errorf("Itoa(%v) = %v want %v\n",
                                                test.in, s, test.out);
                                }
 
                                if test.in >= 0 {
-                                       s := strconv.Uitoa(uint(test.in));
+                                       s := Uitoa(uint(test.in));
                                        if s != test.out {
-                                               t.Errorf("strconv.Uitoa(%v) = %v want %v\n",
+                                               t.Errorf("Uitoa(%v) = %v want %v\n",
                                                        test.in, s, test.out);
                                        }
                                }
@@ -141,31 +141,31 @@ var uitob64tests = []uitob64Test {
 
 func TestUitoa(t *testing.T) {
        for i, test := range uitob64tests {
-               s := strconv.Uitob64(test.in, test.base);
+               s := Uitob64(test.in, test.base);
                if s != test.out {
-                       t.Errorf("strconv.Uitob64(%v, %v) = %v want %v\n",
+                       t.Errorf("Uitob64(%v, %v) = %v want %v\n",
                                test.in, test.base, s, test.out);
                }
 
                if uint64(uint(test.in)) == test.in {
-                       s := strconv.Uitob(uint(test.in), test.base);
+                       s := Uitob(uint(test.in), test.base);
                        if s != test.out {
-                               t.Errorf("strconv.Uitob(%v, %v) = %v want %v\n",
+                               t.Errorf("Uitob(%v, %v) = %v want %v\n",
                                        test.in, test.base, s, test.out);
                        }
                }
 
                if test.base == 10 {
-                       s := strconv.Uitoa64(test.in);
+                       s := Uitoa64(test.in);
                        if s != test.out {
-                               t.Errorf("strconv.Uitoa64(%v) = %v want %v\n",
+                               t.Errorf("Uitoa64(%v) = %v want %v\n",
                                        test.in, s, test.out);
                        }
 
                        if uint64(uint(test.in)) == test.in {
-                               s := strconv.Uitoa(uint(test.in));
+                               s := Uitoa(uint(test.in));
                                if s != test.out {
-                                       t.Errorf("strconv.Uitoa(%v) = %v want %v\n",
+                                       t.Errorf("Uitoa(%v) = %v want %v\n",
                                                test.in, s, test.out);
                                }
                        }
index 0b35b20cc7a64501e23a60204712632cc3929923..a3d7ab939fadfee144f8321d256ad0d449762c1f 100644 (file)
@@ -2,11 +2,11 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package strconv
+package strconv_test
 
 import (
        "os";
-       "strconv";
+       "strconv";
        "testing";
 )
 
index 566853d576a60703b825943d39e8c2e33a599b91..0c18f8bcbce68fe61168584ad1fe45f105f737a4 100644 (file)
@@ -2,60 +2,13 @@
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
-# DO NOT EDIT.  Automatically generated by gobuild.
-# gobuild -m asm_${GOARCH}.s mutex.go >Makefile
-
-D=
-
 include $(GOROOT)/src/Make.$(GOARCH)
-AR=gopack
-
-default: packages
-
-clean:
-       rm -rf *.[$(OS)] *.a [$(OS)].out _obj
-
-test: packages
-       gotest
-
-coverage: packages
-       gotest
-       6cov -g `pwd` | grep -v '_test\.go:'
-
-%.$O: %.go
-       $(GC) -I_obj $*.go
-
-%.$O: %.c
-       $(CC) $*.c
 
-%.$O: %.s
-       $(AS) $*.s
+TARG=sync
+GOFILES=\
+       mutex.go\
 
-O1=\
+OFILES=\
        asm_$(GOARCH).$O\
-       mutex.$O\
-
-
-phases: a1
-_obj$D/sync.a: phases
-
-a1: $(O1)
-       $(AR) grc _obj$D/sync.a asm_$(GOARCH).$O mutex.$O
-       rm -f $(O1)
-
-
-newpkg: clean
-       mkdir -p _obj$D
-       $(AR) grc _obj$D/sync.a
-
-$(O1): newpkg
-$(O2): a1
-
-nuke: clean
-       rm -f $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/sync.a
-
-packages: _obj$D/sync.a
 
-install: packages
-       test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D
-       cp _obj$D/sync.a $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/sync.a
+include $(GOROOT)/src/Make.pkg
diff --git a/src/pkg/sync/internal_test.go b/src/pkg/sync/internal_test.go
new file mode 100644 (file)
index 0000000..e6027cf
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// expose internals for testing
+
+package sync
+
+func Semacquire(s *int32) {
+       semacquire(s)
+}
+
+func Semrelease(s *int32) {
+       semrelease(s)
+}
index 819dbb9de55e8dd54fae387ca27351d4fa15a5e3..e1f6a17bd99aea10e8bd759742a41a8958b80c19 100644 (file)
@@ -4,17 +4,17 @@
 
 // GOMAXPROCS=10 gotest
 
-package sync
+package sync_test
 
 import (
-       "sync";
+       "sync";
        "testing"
 )
 
 func HammerSemaphore(s *int32, cdone chan bool) {
        for i := 0; i < 1000; i++ {
-               semacquire(s);
-               semrelease(s);
+               Semacquire(s);
+               Semrelease(s);
        }
        cdone <- true;
 }
index 8d3c3b65f6b1fdfb12a4c50a83c3214c3a6845f0..fef9753c876f56fbbe3071b15226dbcb94107371 100644 (file)
@@ -2,76 +2,13 @@
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
-# DO NOT EDIT.  Automatically generated by gobuild.
-# gobuild -m >Makefile
-
-D=
-
 include $(GOROOT)/src/Make.$(GOARCH)
-AR=gopack
-
-default: packages
-
-clean:
-       rm -rf *.[$(OS)] *.a [$(OS)].out _obj
-
-test: packages
-       gotest
-
-coverage: packages
-       gotest
-       6cov -g `pwd` | grep -v '_test\.go:'
-
-%.$O: %.go
-       $(GC) -I_obj $*.go
-
-%.$O: %.c
-       $(CC) $*.c
-
-%.$O: %.s
-       $(AS) $*.s
-
-O1=\
-       sleep.$O\
-       zoneinfo.$O\
-
-O2=\
-       time.$O\
-
-O3=\
-       tick.$O\
-
-
-phases: a1 a2 a3
-_obj$D/time.a: phases
-
-a1: $(O1)
-       $(AR) grc _obj$D/time.a sleep.$O zoneinfo.$O
-       rm -f $(O1)
-
-a2: $(O2)
-       $(AR) grc _obj$D/time.a time.$O
-       rm -f $(O2)
-
-a3: $(O3)
-       $(AR) grc _obj$D/time.a tick.$O
-       rm -f $(O3)
-
-
-newpkg: clean
-       mkdir -p _obj$D
-       $(AR) grc _obj$D/time.a
-
-$(O1): newpkg
-$(O2): a1
-$(O3): a2
-$(O4): a3
-
-nuke: clean
-       rm -f $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/time.a
 
-packages: _obj$D/time.a
+TARG=time
+GOFILES=\
+       sleep.go\
+       tick.go\
+       time.go\
+       zoneinfo.go\
 
-install: packages
-       test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D
-       cp _obj$D/time.a $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/time.a
+include $(GOROOT)/src/Make.pkg
index 26de901250e1894e4195d44ca1afad799531acfb..81c38522033f4a9f6750567e3d03cbbb1750a2da 100644 (file)
@@ -6,7 +6,6 @@ package time
 
 import (
        "syscall";
-       "time";
        "unsafe";
 )
 
index 0667be679b6b8a747989b35cca8d49724e1a9e86..c7cad1217eba5ff0f1b487342e64fb2744b33a56 100644 (file)
@@ -2,11 +2,11 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package time
+package time_test
 
 import (
        "testing";
-       "time";
+       "time";
 )
 
 func TestTick(t *testing.T) {
index d47dbe6a11cfe6705ad3031c263f208a2836d7a8..1e4990b10f0e05d47c76ea34961a01e06625d57a 100644 (file)
@@ -8,7 +8,6 @@ package time
 
 import (
        "os";
-       "time"
 )
 
 // Seconds reports the number of seconds since the Unix epoch,
index 2457d8561ada638d055c61f46c09bb17d0a1fac0..2c80a716dc1683af0ae5c51e2427be83de34bfc0 100644 (file)
@@ -2,12 +2,12 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package time
+package time_test
 
 import (
        "os";
        "testing";
-       "time";
+       "time";
 )
 
 func init() {
index b5ad083b2d4a292c9a4b28ae08d4f778822d0ad3..b33adaa8a1160260886b217f0e55830dfe720f71 100644 (file)
@@ -2,59 +2,10 @@
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
-# DO NOT EDIT.  Automatically generated by gobuild.
-# gobuild -m >Makefile
-
-D=
-
 include $(GOROOT)/src/Make.$(GOARCH)
-AR=gopack
-
-default: packages
-
-clean:
-       rm -rf *.[$(OS)] *.a [$(OS)].out _obj
-
-test: packages
-       gotest
-
-coverage: packages
-       gotest
-       6cov -g `pwd` | grep -v '_test\.go:'
-
-%.$O: %.go
-       $(GC) -I_obj $*.go
-
-%.$O: %.c
-       $(CC) $*.c
-
-%.$O: %.s
-       $(AS) $*.s
-
-O1=\
-       utf8.$O\
-
-
-phases: a1
-_obj$D/utf8.a: phases
-
-a1: $(O1)
-       $(AR) grc _obj$D/utf8.a utf8.$O
-       rm -f $(O1)
-
-
-newpkg: clean
-       mkdir -p _obj$D
-       $(AR) grc _obj$D/utf8.a
-
-$(O1): newpkg
-$(O2): a1
-
-nuke: clean
-       rm -f $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/utf8.a
 
-packages: _obj$D/utf8.a
+TARG=utf8
+GOFILES=\
+       utf8.go\
 
-install: packages
-       test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D
-       cp _obj$D/utf8.a $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/utf8.a
+include $(GOROOT)/src/Make.pkg
index 1597a94c72ff4fa8eb227e9f3ddfe19933b99ddc..9c689ca2db8f48f4e58fc87855db8fccbb9993d1 100644 (file)
@@ -2,14 +2,14 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package utf8
+package utf8_test
 
 import (
        "bytes";
        "fmt";
        "strings";
        "testing";
-       "utf8";
+       "utf8";
 )
 
 type Utf8Map struct {
@@ -56,19 +56,19 @@ func TestFullRune(t *testing.T) {
        for i := 0; i < len(utf8map); i++ {
                m := utf8map[i];
                b := makeBytes(m.str);
-               if !utf8.FullRune(b) {
+               if !FullRune(b) {
                        t.Errorf("FullRune(%q) (rune %04x) = false, want true", b, m.rune);
                }
                s := m.str;
-               if !utf8.FullRuneInString(s) {
+               if !FullRuneInString(s) {
                        t.Errorf("FullRuneInString(%q) (rune %04x) = false, want true", s, m.rune);
                }
                b1 := b[0:len(b)-1];
-               if utf8.FullRune(b1) {
+               if FullRune(b1) {
                        t.Errorf("FullRune(%q) = true, want false", b1);
                }
                s1 := string(b1);
-               if utf8.FullRuneInString(s1) {
+               if FullRuneInString(s1) {
                        t.Errorf("FullRune(%q) = true, want false", s1);
                }
        }
@@ -79,7 +79,7 @@ func TestEncodeRune(t *testing.T) {
                m := utf8map[i];
                b := makeBytes(m.str);
                var buf [10]byte;
-               n := utf8.EncodeRune(m.rune, &buf);
+               n := EncodeRune(m.rune, &buf);
                b1 := buf[0:n];
                if !bytes.Equal(b, b1) {
                        t.Errorf("EncodeRune(0x%04x) = %q want %q", m.rune, b1, b);
@@ -91,23 +91,23 @@ func TestDecodeRune(t *testing.T) {
        for i := 0; i < len(utf8map); i++ {
                m := utf8map[i];
                b := makeBytes(m.str);
-               rune, size := utf8.DecodeRune(b);
+               rune, size := DecodeRune(b);
                if rune != m.rune || size != len(b) {
                        t.Errorf("DecodeRune(%q) = 0x%04x, %d want 0x%04x, %d", b, rune, size, m.rune, len(b));
                }
                s := m.str;
-               rune, size = utf8.DecodeRuneInString(s);
+               rune, size = DecodeRuneInString(s);
                if rune != m.rune || size != len(b) {
                        t.Errorf("DecodeRune(%q) = 0x%04x, %d want 0x%04x, %d", s, rune, size, m.rune, len(b));
                }
 
                // there's an extra byte that bytes left behind - make sure trailing byte works
-               rune, size = utf8.DecodeRune(b[0:cap(b)]);
+               rune, size = DecodeRune(b[0:cap(b)]);
                if rune != m.rune || size != len(b) {
                        t.Errorf("DecodeRune(%q) = 0x%04x, %d want 0x%04x, %d", b, rune, size, m.rune, len(b));
                }
                s = m.str+"\x00";
-               rune, size = utf8.DecodeRuneInString(s);
+               rune, size = DecodeRuneInString(s);
                if rune != m.rune || size != len(b) {
                        t.Errorf("DecodeRuneInString(%q) = 0x%04x, %d want 0x%04x, %d", s, rune, size, m.rune, len(b));
                }
@@ -117,12 +117,12 @@ func TestDecodeRune(t *testing.T) {
                if wantsize >= len(b) {
                        wantsize = 0;
                }
-               rune, size = utf8.DecodeRune(b[0:len(b)-1]);
+               rune, size = DecodeRune(b[0:len(b)-1]);
                if rune != RuneError || size != wantsize {
                        t.Errorf("DecodeRune(%q) = 0x%04x, %d want 0x%04x, %d", b[0:len(b)-1], rune, size, RuneError, wantsize);
                }
                s = m.str[0:len(m.str)-1];
-               rune, size = utf8.DecodeRuneInString(s);
+               rune, size = DecodeRuneInString(s);
                if rune != RuneError || size != wantsize {
                        t.Errorf("DecodeRuneInString(%q) = 0x%04x, %d want 0x%04x, %d", s, rune, size, RuneError, wantsize);
                }
@@ -133,12 +133,12 @@ func TestDecodeRune(t *testing.T) {
                } else {
                        b[len(b)-1] = 0x7F;
                }
-               rune, size = utf8.DecodeRune(b);
+               rune, size = DecodeRune(b);
                if rune != RuneError || size != 1 {
                        t.Errorf("DecodeRune(%q) = 0x%04x, %d want 0x%04x, %d", b, rune, size, RuneError, 1);
                }
                s = string(b);
-               rune, size = utf8.DecodeRune(b);
+               rune, size = DecodeRune(b);
                if rune != RuneError || size != 1 {
                        t.Errorf("DecodeRuneInString(%q) = 0x%04x, %d want 0x%04x, %d", s, rune, size, RuneError, 1);
                }
@@ -158,10 +158,10 @@ var runecounttests = []RuneCountTest {
 func TestRuneCount(t *testing.T) {
        for i := 0; i < len(runecounttests); i++ {
                tt := runecounttests[i];
-               if out := utf8.RuneCountInString(tt.in); out != tt.out {
+               if out := RuneCountInString(tt.in); out != tt.out {
                        t.Errorf("RuneCountInString(%q) = %d, want %d", tt.in, out, tt.out);
                }
-               if out := utf8.RuneCount(makeBytes(tt.in)); out != tt.out {
+               if out := RuneCount(makeBytes(tt.in)); out != tt.out {
                        t.Errorf("RuneCount(%q) = %d, want %d", tt.in, out, tt.out);
                }
        }