Sha256: c627954dec6eb83b740884d6ba1569067e30c3bbdecb40fdfb57a6f1ae57f4e3

Contents?: true

Size: 1.01 KB

Versions: 68

Compression:

Stored size: 1.01 KB

Contents

package main

import (
	"log"
	"text/template"

	"../../../gen"
)

func main() {
	t, err := template.New("").Parse(tmpl)
	if err != nil {
		log.Fatal(err)
	}
	var j js
	if err := gen.Gen("scale-generator", &j, t); err != nil {
		log.Fatal(err)
	}
}

// The JSON structure we expect to be able to unmarshal into
type js struct {
	Cases []struct {
		Comments    []string
		Description string
		Cases       []struct {
			Description string
			Property    string
			Input       struct {
				Tonic     string
				Intervals string
			}
			Expected []string
		}
	}
}

// template applied to above data structure generates the Go test cases
var tmpl = `package scale

{{.Header}}

type scaleTest struct {
	description string
	tonic    string
	interval string
	expected []string
}

var scaleTestCases = []scaleTest {
{{range .J.Cases}} {{range .Cases}}{
	description: {{printf "%q" .Description }},
	tonic: {{printf "%q" .Input.Tonic }},
	interval: {{printf "%q" .Input.Intervals }},
	expected: {{printf "%#v" .Expected }},
},
{{end}}{{end}}
}
`

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.179 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.178 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.177 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.176 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.175 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.174 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.173 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.172 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.171 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.170 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.169 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.167 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.166 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.165 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.164 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.163 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.162 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.161 tracks/go/exercises/scale-generator/.meta/gen.go
trackler-2.2.1.160 tracks/go/exercises/scale-generator/.meta/gen.go