f8d9fa9e80
This upgrades all of libgo other than the runtime package to the Go 1.4 release. In Go 1.4 much of the runtime was rewritten into Go. Merging that code will take more time and will not change the API, so I'm putting it off for now. There are a few runtime changes anyhow, to accomodate other packages that rely on minor modifications to the runtime support. The compiler changes slightly to add a one-bit flag to each type descriptor kind that is stored directly in an interface, which for gccgo is currently only pointer types. Another one-bit flag (gcprog) is reserved because it is used by the gc compiler, but gccgo does not currently use it. There is another error check in the compiler since I ran across it during testing. gotools/: * Makefile.am (go_cmd_go_files): Sort entries. Add generate.go. * Makefile.in: Rebuild. From-SVN: r219627
48 lines
1017 B
Go
48 lines
1017 B
Go
// Copyright 2013 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.
|
|
|
|
package syscall_test
|
|
|
|
import (
|
|
"fmt"
|
|
"syscall"
|
|
"testing"
|
|
)
|
|
|
|
func testSetGetenv(t *testing.T, key, value string) {
|
|
err := syscall.Setenv(key, value)
|
|
if err != nil {
|
|
t.Fatalf("Setenv failed to set %q: %v", value, err)
|
|
}
|
|
newvalue, found := syscall.Getenv(key)
|
|
if !found {
|
|
t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value)
|
|
}
|
|
if newvalue != value {
|
|
t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value)
|
|
}
|
|
}
|
|
|
|
func TestEnv(t *testing.T) {
|
|
testSetGetenv(t, "TESTENV", "AVALUE")
|
|
// make sure TESTENV gets set to "", not deleted
|
|
testSetGetenv(t, "TESTENV", "")
|
|
}
|
|
|
|
func TestItoa(t *testing.T) {
|
|
// Make most negative integer: 0x8000...
|
|
i := 1
|
|
for i<<1 != 0 {
|
|
i <<= 1
|
|
}
|
|
if i >= 0 {
|
|
t.Fatal("bad math")
|
|
}
|
|
s := syscall.Itoa(i)
|
|
f := fmt.Sprint(i)
|
|
if s != f {
|
|
t.Fatalf("itoa(%d) = %s, want %s", i, s, f)
|
|
}
|
|
}
|