rename test to about
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package go_koans
|
||||
|
||||
func testAllocation() {
|
||||
func aboutAllocation() {
|
||||
a := new(int)
|
||||
*a = 3
|
||||
assert(*a == __int__) // new() creates a pointer to the given type, like malloc() in C
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package go_koans
|
||||
|
||||
func testAnonymousFunctions() {
|
||||
func aboutAnonymousFunctions() {
|
||||
{
|
||||
i := 1
|
||||
increment := func() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package go_koans
|
||||
|
||||
func testArrays() {
|
||||
func aboutArrays() {
|
||||
fruits := [4]string{"apple", "orange", "mango"}
|
||||
|
||||
assert(fruits[0] == __string__) // indexes begin at 0
|
||||
|
||||
@@ -2,7 +2,7 @@ package go_koans
|
||||
|
||||
import "fmt"
|
||||
|
||||
func testControlFlow() {
|
||||
func aboutControlFlow() {
|
||||
{
|
||||
a, b, c := 1, 2, 3
|
||||
assert(a == __int__) // multiple assignment
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package go_koans
|
||||
|
||||
func testEnumeration() {
|
||||
func aboutEnumeration() {
|
||||
{
|
||||
var concatenated string
|
||||
var total int
|
||||
|
||||
@@ -3,7 +3,7 @@ package go_koans
|
||||
import "io/ioutil"
|
||||
import "strings"
|
||||
|
||||
func testFiles() {
|
||||
func aboutFiles() {
|
||||
filename := "about_files.go"
|
||||
contents, _ := ioutil.ReadFile(filename)
|
||||
lines := strings.Split(string(contents), "\n")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package go_koans
|
||||
|
||||
func testInterfaces() {
|
||||
func aboutInterfaces() {
|
||||
mspaint := &program{3} // mspaint is a kind of *program, which is a valid 'runner'
|
||||
runOnce(mspaint) // runOnce takes an abstract 'runner' type
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package go_koans
|
||||
|
||||
func testMaps() {
|
||||
func aboutMaps() {
|
||||
ages := map[string]int{
|
||||
"bob": 10,
|
||||
"joe": 20,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package go_koans
|
||||
|
||||
func testNumbers() {
|
||||
func aboutNumbers() {
|
||||
assert(__bool__ == true) // what is truth?
|
||||
assert(__bool__ != false) // in it there is nothing false
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package go_koans
|
||||
|
||||
func testPointers() {
|
||||
func aboutPointers() {
|
||||
{
|
||||
a := 3
|
||||
b := a // 'b' is a copy of 'a' (all assignments are copy-operations)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package go_koans
|
||||
|
||||
func testSlices() {
|
||||
func aboutSlices() {
|
||||
fruits := []string{"apple", "orange", "mango"}
|
||||
|
||||
assert(fruits[0] == __string__) // slices seem like arrays
|
||||
|
||||
@@ -2,7 +2,7 @@ package go_koans
|
||||
|
||||
import "fmt"
|
||||
|
||||
func testStrings() {
|
||||
func aboutStrings() {
|
||||
assert("a" + __string__ == "abc") // string concatenation need not be difficult
|
||||
assert(len("abc") == __int__) // and bounds are thoroughly checked
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package go_koans
|
||||
|
||||
func testStructs() {
|
||||
func aboutStructs() {
|
||||
var bob struct {
|
||||
name string
|
||||
age int
|
||||
|
||||
@@ -6,7 +6,7 @@ func concatNames(sep string, names ...string) string {
|
||||
return strings.Join(names, sep) // variadic parameters are really just slices
|
||||
}
|
||||
|
||||
func testVariadicFunctions() {
|
||||
func aboutVariadicFunctions() {
|
||||
{
|
||||
str := concatNames(" ", "bob", "billy", "fred")
|
||||
assert(str == __string__) // several values can be passed to variadic parameters
|
||||
|
||||
@@ -17,25 +17,25 @@ var __bool__ bool = false // ugh
|
||||
var __float32__ float32 = -1.0
|
||||
|
||||
func TestKoans(t *testing.T) {
|
||||
//testNumbers()
|
||||
//testStrings()
|
||||
//testArrays()
|
||||
//testSlices()
|
||||
//testControlFlow()
|
||||
//testEnumeration()
|
||||
//testAnonymousFunctions()
|
||||
//testVariadicFunctions()
|
||||
//testFiles()
|
||||
//testInterfaces()
|
||||
//testMaps()
|
||||
//testPointers()
|
||||
//testStructs()
|
||||
testAllocation()
|
||||
//aboutNumbers()
|
||||
//aboutStrings()
|
||||
//aboutArrays()
|
||||
//aboutSlices()
|
||||
//aboutControlFlow()
|
||||
//aboutEnumeration()
|
||||
//aboutAnonymousFunctions()
|
||||
//aboutVariadicFunctions()
|
||||
//aboutFiles()
|
||||
//aboutInterfaces()
|
||||
//aboutMaps()
|
||||
//aboutPointers()
|
||||
//aboutStructs()
|
||||
aboutAllocation()
|
||||
|
||||
// TODO: ie, gameplan
|
||||
//testGoroutines()
|
||||
//testChannels()
|
||||
//testPanics()
|
||||
//aboutGoroutines()
|
||||
//aboutChannels()
|
||||
//aboutPanics()
|
||||
|
||||
fmt.Printf("\n%c[32;1mYou won life. Good job.\n\n", 27)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user