Skip to content

Instantly share code, notes, and snippets.

@justincampbell
Created July 31, 2014 15:14
Show Gist options
  • Save justincampbell/5ee66ff315cdf54bfbc2 to your computer and use it in GitHub Desktop.
Save justincampbell/5ee66ff315cdf54bfbc2 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
)
var noTime time.Time
func main() {
fmt.Println("Hi.")
}
package main
import (
"testing"
"time"
"github.com/bmizerany/assert"
)
func TestAssertEaual(t *testing.T) {
aTime, _ := time.Parse(time.Kitchen, "1:23AM")
assert.Equal(t, aTime, noTime)
}
func TestEqualMethod(t *testing.T) {
aTime, _ := time.Parse(time.Kitchen, "1:23AM")
assert.T(t, aTime.Equal(noTime))
}
unexported_return_error$ go test -run Method
--- FAIL: TestEqualMethod (0.00 seconds)
assert.go:15: /Users/Justin/Dropbox/Code/playground/unexported_return_error/main_test.go:18
assert.go:36: ! Failure
FAIL
exit status 1
FAIL _/Users/Justin/Dropbox/Code/playground/unexported_return_error 0.011s
1 unexported_return_error$ go test -run Assert
--- FAIL: TestAssertEaual (0.00 seconds)
assert.go:15: /Users/Justin/Dropbox/Code/playground/unexported_return_error/main_test.go:13
panic: reflect.Value.Interface: cannot return value obtained from unexported field or method [recovered]
panic: reflect.Value.Interface: cannot return value obtained from unexported field or method
goroutine 20 [running]:
runtime.panic(0xfbb40, 0x208260420)
/usr/local/Cellar/go/1.3/libexec/src/pkg/runtime/panic.c:279 +0xf5
testing.func·006()
/usr/local/Cellar/go/1.3/libexec/src/pkg/testing/testing.go:416 +0x176
runtime.panic(0xfbb40, 0x208260420)
/usr/local/Cellar/go/1.3/libexec/src/pkg/runtime/panic.c:248 +0x18d
reflect.valueInterface(0xfb840, 0x20826e0c0, 0x0, 0x63, 0xfb801, 0x0, 0x0)
/usr/local/Cellar/go/1.3/libexec/src/pkg/reflect/value.go:1081 +0x10c
reflect.Value.Interface(0xfb840, 0x20826e0c0, 0x0, 0x63, 0x0, 0x0)
/usr/local/Cellar/go/1.3/libexec/src/pkg/reflect/value.go:1070 +0x5c
github.com/kr/pretty.diffWriter.diff(0x2208272610, 0x20826e100, 0x155e10, 0x3, 0xfb840, 0x20826e0c0, 0x0, 0x63, 0xfb840, 0x20826e0e0, ...)
/Users/Justin/Code/go/src/github.com/kr/pretty/diff.go:63 +0x47d
github.com/kr/pretty.diffWriter.diff(0x2208272610, 0x20826e100, 0x0, 0x0, 0x14a2e0, 0x20826e0c0, 0x0, 0x192, 0x14a2e0, 0x20826e0e0, ...)
/Users/Justin/Code/go/src/github.com/kr/pretty/diff.go:87 +0x2502
github.com/kr/pretty.Fdiff(0x2208272610, 0x20826e100, 0x14a2e0, 0x20826e0c0, 0x14a2e0, 0x20826e0e0)
/Users/Justin/Code/go/src/github.com/kr/pretty/diff.go:25 +0x155
github.com/kr/pretty.Diff(0x14a2e0, 0x20826e0c0, 0x14a2e0, 0x20826e0e0, 0x0, 0x0, 0x0)
/Users/Justin/Code/go/src/github.com/kr/pretty/diff.go:19 +0xb0
github.com/bmizerany/assert.func·001()
/Users/Justin/Code/go/src/github.com/bmizerany/assert/assert.go:23 +0x5d
github.com/bmizerany/assert.assert(0x2082b6090, 0x20826e000, 0x2208429e58, 0x2)
/Users/Justin/Code/go/src/github.com/bmizerany/assert/assert.go:16 +0x148
github.com/bmizerany/assert.equal(0x2082b6090, 0x14a2e0, 0x20826e0c0, 0x14a2e0, 0x20826e0e0, 0x1, 0x0, 0x0, 0x0)
/Users/Justin/Code/go/src/github.com/bmizerany/assert/assert.go:31 +0xcd
github.com/bmizerany/assert.Equal(0x2082b6090, 0x14a2e0, 0x20826e0c0, 0x14a2e0, 0x20826e0e0, 0x0, 0x0, 0x0)
/Users/Justin/Code/go/src/github.com/bmizerany/assert/assert.go:53 +0x81
_/Users/Justin/Dropbox/Code/playground/unexported_return_error.TestAssertEaual(0x2082b6090)
/Users/Justin/Dropbox/Code/playground/unexported_return_error/main_test.go:13 +0x11e
testing.tRunner(0x2082b6090, 0x214160)
/usr/local/Cellar/go/1.3/libexec/src/pkg/testing/testing.go:422 +0x8b
created by testing.RunTests
/usr/local/Cellar/go/1.3/libexec/src/pkg/testing/testing.go:504 +0x8db
goroutine 16 [chan receive]:
testing.RunTests(0x195810, 0x214160, 0x2, 0x2, 0x1)
/usr/local/Cellar/go/1.3/libexec/src/pkg/testing/testing.go:505 +0x923
testing.Main(0x195810, 0x214160, 0x2, 0x2, 0x21f820, 0x0, 0x0, 0x21f820, 0x0, 0x0)
/usr/local/Cellar/go/1.3/libexec/src/pkg/testing/testing.go:435 +0x84
main.main()
_/Users/Justin/Dropbox/Code/playground/unexported_return_error/_test/_testmain.go:49 +0x9c
goroutine 19 [finalizer wait]:
runtime.park(0x144f0, 0x21c3f0, 0x21b7a9)
/usr/local/Cellar/go/1.3/libexec/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0x21c3f0, 0x21b7a9)
/usr/local/Cellar/go/1.3/libexec/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
/usr/local/Cellar/go/1.3/libexec/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
/usr/local/Cellar/go/1.3/libexec/src/pkg/runtime/proc.c:1445
exit status 2
FAIL _/Users/Justin/Dropbox/Code/playground/unexported_return_error 0.014s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment