Sha256: 98996b49eeb22769d5b19a976d29f3e5b9eeabc80c3353ab45858c98a4e8cf2c

Contents?: true

Size: 971 Bytes

Versions: 76

Compression:

Stored size: 971 Bytes

Contents

// +build ignore

package main

import (
	"log"
	"strings"
	"text/template"

	"../../gen"
)

func main() {
	m := template.FuncMap{"week": strings.Title}
	t, err := template.New("").Funcs(m).Parse(tmpl)
	if err != nil {
		log.Fatal(err)
	}
	var j js
	if err := gen.Gen("meetup", &j, t); err != nil {
		log.Fatal(err)
	}
}

// The JSON structure we expect to be able to unmarshal into
type js struct {
	Cases []struct {
		Description string
		Year        int
		Month       int
		Week        string
		Dayofweek   string
		Dayofmonth  int
	}
}

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

// Source: {{.Ori}}
{{if .Commit}}// Commit: {{.Commit}}
{{end}}

import "time"

var testCases = []struct {
	year    int
	month   time.Month
	week    WeekSchedule
	weekday time.Weekday
	expDay  int
}{
{{range .J.Cases}}{ {{.Year}}, {{.Month}}, {{week .Week}}, time.{{.Dayofweek}}, {{.Dayofmonth}}}, // {{.Description}}
{{end}}}
`

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
trackler-2.0.8.43 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.42 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.41 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.40 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.39 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.38 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.37 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.36 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.35 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.34 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.33 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.32 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.31 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.30 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.29 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.28 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.27 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.26 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.24 tracks/go/exercises/meetup/example_gen.go
trackler-2.0.8.23 tracks/go/exercises/meetup/example_gen.go