<commit_before>// Copyright © 2009 <NAME> <www.orfjackal.net>
// This software is released under the Apache License 2.0.
// The license text is at http://www.apache.org/licenses/LICENSE-2.0

package gospec

import (
	"fmt"
	"io"
)


type PrintFormat interface {
	PrintPassing(nestingLevel int, name string)
	PrintFailing(nestingLevel int, name string, errors []*Error)
	PrintSummary(passCount int, failCount int)
}


// PrintFormat for production use.
func DefaultPrintFormat(out io.Writer) PrintFormat {
	return &defaultPrintFormat{out}
}

type defaultPrintFormat struct {
	out io.Writer
}

func (this *defaultPrintFormat) PrintPassing(nestingLevel int, name string) {
	if nestingLevel == 0 {
		fmt.Fprintf(this.out, "\n%v\n", name)
	} else {
		indent := indent(nestingLevel)
		fmt.Fprintf(this.out, "%v- %v\n", indent, name)
	}
}

func (this *defaultPrintFormat) PrintFailing(nestingLevel int, name string, errors []*Error) {
	indent := indent(nestingLevel)
	// TODO: use colors (red)
	fmt.Fprintf(this.out, "%v- %v [FAIL]\n", indent, name)
	for _, error := range errors {
		fmt.Fprintf(this.out, "[ERROR] %v\n\t%v\n", error.Location, error.Message)
	}
}

func (this *defaultPrintFormat) PrintSummary(passCount int, failCount int) {
	totalCount := passCount + failCount
	// TODO: use colors (red if failures, else green)
	fmt.Fprintf(this.out, "\n%v specs, %v failures\n", totalCount, failCount)
}


// PrintFormat for use in only tests. Does not print line numbers, colors or
// other fancy stuff. Makes comparing as a string easier.
func SimplePrintFormat(out io.Writer) PrintFormat {
	return &simplePrintFormat{out}
}

type simplePrintFormat struct {
	out io.Writer
}

func (this *simplePrintFormat) PrintPassing(nestingLevel int, name string) {
	indent := indent(nestingLevel)<commit_msg>More empty space after error messages, to keep them separate from the next spec's name<commit_after>// Copyright © 2009 <NAME> <www.orfjackal.net>
// This software is released under the Apache License 2.0.
// The license text is at http://www.apache.org/licenses/LICENSE-2.0

package gospec

import (
	"fmt"
	"io"
)


type PrintFormat interface {
	PrintPassing(nestingLevel int, name string)
	PrintFailing(nestingLevel int, name string, errors []*Error)
	PrintSummary(passCount int, failCount int)
}


// PrintFormat for production use.
func DefaultPrintFormat(out io.Writer) PrintFormat {
	return &defaultPrintFormat{out}
}

type defaultPrintFormat struct {
	out io.Writer
}

func (this *defaultPrintFormat) PrintPassing(nestingLevel int, name string) {
	if nestingLevel == 0 {
		fmt.Fprintf(this.out, "\n%v\n", name)
	} else {
		indent := indent(nestingLevel)
		fmt.Fprintf(this.out, "%v- %v\n", indent, name)
	}
}

func (this *defaultPrintFormat) PrintFailing(nestingLevel int, name string, errors []*Error) {
	indent := indent(nestingLevel)
	// TODO: use colors (red)
	fmt.Fprintf(this.out, "%v- %v [FAIL]\n", indent, name)
	for _, error := range errors {
		fmt.Fprintf(this.out, "[ERROR] %v\n\t%v\n", error.Location, error.Message)
	}
	fmt.Fprint(this.out, "\n")
}

func (this *defaultPrintFormat) PrintSummary(passCount int, failCount int) {
	totalCount := passCount + failCount
	// TODO: use colors (red if failures, else green)
	fmt.Fprintf(this.out, "\n%v specs, %v failures\n", totalCount, failCount)
}


// PrintFormat for use in only tests. Does not print line numbers, colors or
// other fancy stuff. Makes comparing as a string easier.
func SimplePrintFormat(out io.Writer) PrintFormat {
	return &simplePrintFormat{out}
}

type simplePrintFormat struct {
	out io.Writer
}

func (this *simplePrintFormat) PrintPassing(nestingLevel int, name string) {
	indent := indent(nestingLevel)
{'fraction_non_alphanumeric': 0.12415288696123611, 'fraction_numerical': 0.004879371103280022, 'mean_word_length': 4.633587786259542, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6116204', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1203, 'n_words': 367}