commit 4c5e766472be1885ea0dc3a4b3302b7ae1f3ea11 Author: Steven Degutis Date: Sat Mar 10 12:47:04 2012 -0600 first diff --git a/goans_test.go b/goans_test.go new file mode 100644 index 0000000..3b4fb51 --- /dev/null +++ b/goans_test.go @@ -0,0 +1,5 @@ +package goans + +func testBasics() { + assert(__ == true) // what is truth? +} diff --git a/setup_koans_test.go b/setup_koans_test.go new file mode 100644 index 0000000..b1c76e5 --- /dev/null +++ b/setup_koans_test.go @@ -0,0 +1,33 @@ +package goans + +import ( + "testing" + "os" + "fmt" + "runtime" + "io/ioutil" + "path" + "strings" +) + +var __ interface{} + +func TestKoans(t *testing.T) { + testBasics() + fmt.Printf("%c[32m", 27) +} + +func assert(o bool) { + if !o { + fmt.Printf("%c[31m", 27) + fmt.Printf("%s\n\n", __getRecentLine()) + os.Exit(1) + } +} + +func __getRecentLine() string { + _, file, line, _ := runtime.Caller(2) + buf, _ := ioutil.ReadFile(file) + code := strings.TrimSpace(strings.Split(string(buf), "\n")[line-1]) + return fmt.Sprintf("\n%v:%d\n%s", path.Base(file), line, code) +}