summaryrefslogtreecommitdiff
path: root/src/pkg/exp/exception
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2009-12-15 15:27:16 -0800
committerRobert Griesemer <gri@golang.org>2009-12-15 15:27:16 -0800
commit881d6064d23d9da5c7ff368bc7d41d271290deff (patch)
tree44d5d948e3f27cc7eff15ec8cd7ee5165d9a7e90 /src/pkg/exp/exception
parentd9dfea3ebd51cea89fef8afc6b2377c2958b24f1 (diff)
downloadgolang-881d6064d23d9da5c7ff368bc7d41d271290deff.tar.gz
1) Change default gofmt default settings for
parsing and printing to new syntax. Use -oldparser to parse the old syntax, use -oldprinter to print the old syntax. 2) Change default gofmt formatting settings to use tabs for indentation only and to use spaces for alignment. This will make the code alignment insensitive to an editor's tabwidth. Use -spaces=false to use tabs for alignment. 3) Manually changed src/exp/parser/parser_test.go so that it doesn't try to parse the parser's source files using the old syntax (they have new syntax now). 4) gofmt -w src misc test/bench 2nd set of files. R=rsc CC=golang-dev http://codereview.appspot.com/179067
Diffstat (limited to 'src/pkg/exp/exception')
-rw-r--r--src/pkg/exp/exception/exception.go22
-rw-r--r--src/pkg/exp/exception/exception_test.go18
2 files changed, 20 insertions, 20 deletions
diff --git a/src/pkg/exp/exception/exception.go b/src/pkg/exp/exception/exception.go
index 45e0be3f1..e34d0f0d7 100644
--- a/src/pkg/exp/exception/exception.go
+++ b/src/pkg/exp/exception/exception.go
@@ -11,8 +11,8 @@
package exception
import (
- "fmt";
- "runtime";
+ "fmt"
+ "runtime"
)
// A Handler function handles an arbitrary exception value x.
@@ -20,7 +20,7 @@ type Handler func(x interface{})
// An Exception carries an exception value.
type Exception struct {
- Value interface{}; // Value may be the nil exception
+ Value interface{} // Value may be the nil exception
}
// Try invokes a function f with a Handler to throw exceptions.
@@ -51,18 +51,18 @@ type Exception struct {
// })
//
func Try(f func(throw Handler)) *Exception {
- h := make(chan *Exception);
+ h := make(chan *Exception)
// execute try block
go func() {
f(func(x interface{}) {
- h <- &Exception{x};
- runtime.Goexit();
- });
- h <- nil; // clean termination
- }();
+ h <- &Exception{x}
+ runtime.Goexit()
+ })
+ h <- nil // clean termination
+ }()
- return <-h;
+ return <-h
}
@@ -79,5 +79,5 @@ func (x *Exception) String() string {
if x != nil {
return fmt.Sprintf("exception: %v", x.Value)
}
- return "";
+ return ""
}
diff --git a/src/pkg/exp/exception/exception_test.go b/src/pkg/exp/exception/exception_test.go
index 91f742ea0..b7b106d77 100644
--- a/src/pkg/exp/exception/exception_test.go
+++ b/src/pkg/exp/exception/exception_test.go
@@ -7,7 +7,7 @@ package exception
import "testing"
func TestNoException(t *testing.T) {
- e := Try(func(throw Handler) {});
+ e := Try(func(throw Handler) {})
if e != nil {
t.Fatalf("no exception expected, found: %v", e)
}
@@ -15,7 +15,7 @@ func TestNoException(t *testing.T) {
func TestNilException(t *testing.T) {
- e := Try(func(throw Handler) { throw(nil) });
+ e := Try(func(throw Handler) { throw(nil) })
if e == nil {
t.Fatalf("exception expected", e)
}
@@ -26,19 +26,19 @@ func TestNilException(t *testing.T) {
func TestTry(t *testing.T) {
- s := 0;
+ s := 0
for i := 1; i <= 10; i++ {
e := Try(func(throw Handler) {
if i%3 == 0 {
- throw(i);
- panic("throw returned");
+ throw(i)
+ panic("throw returned")
}
- });
+ })
if e != nil {
s += e.Value.(int)
}
}
- result := 3 + 6 + 9;
+ result := 3 + 6 + 9
if s != result {
t.Fatalf("expected: %d, found: %d", result, s)
}
@@ -46,7 +46,7 @@ func TestTry(t *testing.T) {
func TestCatch(t *testing.T) {
- s := 0;
+ s := 0
for i := 1; i <= 10; i++ {
Try(func(throw Handler) {
if i%3 == 0 {
@@ -54,7 +54,7 @@ func TestCatch(t *testing.T) {
}
}).Catch(func(x interface{}) { s += x.(int) })
}
- result := 3 + 6 + 9;
+ result := 3 + 6 + 9
if s != result {
t.Fatalf("expected: %d, found: %d", result, s)
}