moving stuff around or something
This commit is contained in:
8
arrays.go
Normal file
8
arrays.go
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package go_koans
|
||||||
|
|
||||||
|
var __string__ string
|
||||||
|
|
||||||
|
func testArrays() {
|
||||||
|
fruits := [3]string{"apple", "orange"}
|
||||||
|
assert(fruits[0] == __string__)
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
package go_koans
|
package go_koans
|
||||||
|
|
||||||
var __ interface{}
|
var __ bool
|
||||||
|
|
||||||
func testBasics() {
|
func testBasics() {
|
||||||
assert(__ == true) // what is truth?
|
//assert(__ == true) // what is truth?
|
||||||
|
//assert(!__ != true) // in it there is nothing false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,13 +12,15 @@ import (
|
|||||||
|
|
||||||
func TestKoans(t *testing.T) {
|
func TestKoans(t *testing.T) {
|
||||||
testBasics()
|
testBasics()
|
||||||
fmt.Printf("%c[32m", 27)
|
testStrings()
|
||||||
|
testArrays()
|
||||||
|
|
||||||
|
fmt.Printf("\n%c[32;1mYou won life. Good job.\n\n", 27)
|
||||||
}
|
}
|
||||||
|
|
||||||
func assert(o bool) {
|
func assert(o bool) {
|
||||||
if !o {
|
if !o {
|
||||||
fmt.Printf("%c[35m", 27)
|
fmt.Printf("\n%c[35m%s\n\n", 27, __getRecentLine())
|
||||||
fmt.Printf("%s\n\n", __getRecentLine())
|
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,5 +29,5 @@ func __getRecentLine() string {
|
|||||||
_, file, line, _ := runtime.Caller(2)
|
_, file, line, _ := runtime.Caller(2)
|
||||||
buf, _ := ioutil.ReadFile(file)
|
buf, _ := ioutil.ReadFile(file)
|
||||||
code := strings.TrimSpace(strings.Split(string(buf), "\n")[line-1])
|
code := strings.TrimSpace(strings.Split(string(buf), "\n")[line-1])
|
||||||
return fmt.Sprintf("\n%v:%d\n%s", path.Base(file), line, code)
|
return fmt.Sprintf("%v:%d\n%s", path.Base(file), line, code)
|
||||||
}
|
}
|
||||||
|
|||||||
7
strings.go
Normal file
7
strings.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package go_koans
|
||||||
|
|
||||||
|
func testStrings() {
|
||||||
|
//var __ string
|
||||||
|
|
||||||
|
//assert("a" + __ == "abc")
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user