<commit_before>package moka

import (
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Moka", func() {
	var collaborator CollaboratorDouble
	var subject Subject

	var failHandlerCalled bool
	var failHandlerMessage string

	BeforeEach(func() {
		failHandlerCalled = false
		failHandlerMessage = ""
		RegisterDoublesFailHandler(func(message string, _ ...int) {
			failHandlerCalled = true
			failHandlerMessage = message
		})

		collaborator = NewCollaboratorDouble()
		subject = NewSubject(collaborator)
	})

	It("supports allowing a method call on a double", func() {
		AllowDouble(collaborator).To(ReceiveCallTo("Query").With("arg").AndReturn("result"))

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)

		result := subject.DelegateQuery("arg")

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)
		Expect(result).To(Equal("result"))
	})

	It("makes tests fail on unexpected interactions", func() {
		collaborator.Query("unexpected")

		Expect(failHandlerCalled).To(BeTrue())
		Expect(failHandlerMessage).To(Equal("Unexpected interaction: Query(\"unexpected\")"))
	})

	It("supports expecting a method call on a double", func() {
		ExpectDouble(collaborator).To(ReceiveCallTo("Command").With("arg").AndReturn("result", nil))

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)

		result, _ := subject.DelegateCommand("arg")

		Expect(result).To(Equal("result"))

		VerifyCalls(collaborator)

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)
	})

	It("supports allowing a method call on a double without specifying any args", func() {
		AllowDouble(collaborator).To(ReceiveCallTo("Query").AndReturn("result"))

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)

		result := subject.DelegateQuery("anything")

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)
		Expect(result).To(Equal("result"))
	})

	It("supports allowing a method call on a double with variadic args", func() {
		AllowDouble(collaborator).To(ReceiveCallTo("VariadicQuery").With([]string{"arg1", "arg2", "arg3"}).AndReturn("result"))

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)

		result := subject.DelegateVariadicQuery("arg1", "arg2", "arg3")

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)
		Expect(result).To(Equal("result"))
	})
})

type Collaborator interface {
	Query(string) string
	Command(string) (string, error)
	VariadicQuery(...string) string
}

type CollaboratorDouble struct {
	Double
}

func NewCollaboratorDouble() CollaboratorDouble {
	return CollaboratorDouble{Double: NewStrictDoubleWithTypeOf(CollaboratorDouble{})}
}

func (d CollaboratorDouble) Query(arg string) string {
	returnValues, err := d.Call("Query", arg)
	if err != nil {
		return ""
	}

	return returnValues[0].(string)
}

func (d CollaboratorDouble) Command(arg string) (string, error) {
	returnValues, err := d.Call("Command", arg)
	if err != nil {
		return "", nil
	}

	returnedString, _ := returnValues[0].(string)
	returnedError, _ := returnValues[1].(error)

	return returnedString, returnedError
}

func (d CollaboratorDouble) VariadicQuery(args ...string) string {
	returnValues, err := d.Call("VariadicQuery", args)
	if err != nil {
		return ""
	}

	return returnValues[0].(string)
}

type Subject struct {
	collaborator Collaborator
}

func NewSubject(collaborator Collaborator) Subject {
	return Subject{collaborator: collaborator}
}

func (s Subject) DelegateQuery(arg string) string {
	return s.collaborator.Query(arg)
}

func (s Subject) DelegateCommand(arg string) (string, error) {
	return s.collaborator.Command(arg)
}

func (s Subject) DelegateVariadicQuery(args ...string) string {
	return s.collaborator.VariadicQuery(args...)
}
<commit_msg>Test expectation with no args or return values<commit_after>package moka

import (
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Moka", func() {
	var collaborator CollaboratorDouble
	var subject Subject

	var failHandlerCalled bool
	var failHandlerMessage string

	BeforeEach(func() {
		failHandlerCalled = false
		failHandlerMessage = ""
		RegisterDoublesFailHandler(func(message string, _ ...int) {
			failHandlerCalled = true
			failHandlerMessage = message
		})

		collaborator = NewCollaboratorDouble()
		subject = NewSubject(collaborator)
	})

	It("supports allowing a method call on a double", func() {
		AllowDouble(collaborator).To(ReceiveCallTo("Query").With("arg").AndReturn("result"))

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)

		result := subject.DelegateQuery("arg")

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)
		Expect(result).To(Equal("result"))
	})

	It("makes tests fail on unexpected interactions", func() {
		collaborator.Query("unexpected")

		Expect(failHandlerCalled).To(BeTrue())
		Expect(failHandlerMessage).To(Equal("Unexpected interaction: Query(\"unexpected\")"))
	})

	It("supports expecting a method call on a double", func() {
		ExpectDouble(collaborator).To(ReceiveCallTo("Command").With("arg").AndReturn("result", nil))

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)

		result, _ := subject.DelegateCommand("arg")

		Expect(result).To(Equal("result"))

		VerifyCalls(collaborator)

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)
	})

	It("supports allowing a method call on a double without specifying any args", func() {
		AllowDouble(collaborator).To(ReceiveCallTo("Query").AndReturn("result"))

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)

		result := subject.DelegateQuery("anything")

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)
		Expect(result).To(Equal("result"))
	})

	It("supports expecting a method call on a double without specifying any args or return values", func() {
		ExpectDouble(collaborator).To(ReceiveCallTo("CommandWithNoReturnValues"))

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)

		subject.DelegateCommandWithNoReturnValues("arg")
		VerifyCalls(collaborator)

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)
	})

	It("supports allowing a method call on a double with variadic args", func() {
		AllowDouble(collaborator).To(ReceiveCallTo("VariadicQuery").With([]string{"arg1", "arg2", "arg3"}).AndReturn("result"))

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)

		result := subject.DelegateVariadicQuery("arg1", "arg2", "arg3")

		Expect(failHandlerCalled).To(BeFalse(), failHandlerMessage)
		Expect(result).To(Equal("result"))
	})
})

type Collaborator interface {
	Query(string) string
	Command(string) (string, error)
	CommandWithNoReturnValues(string)
	VariadicQuery(...string) string
}

type CollaboratorDouble struct {
	Double
}

func NewCollaboratorDouble() CollaboratorDouble {
	return CollaboratorDouble{Double: NewStrictDoubleWithTypeOf(CollaboratorDouble{})}
}

func (d CollaboratorDouble) Query(arg string) string {
	returnValues, err := d.Call("Query", arg)
	if err != nil {
		return ""
	}

	return returnValues[0].(string)
}

func (d CollaboratorDouble) Command(arg string) (string, error) {
	returnValues, err := d.Call("Command", arg)
	if err != nil {
		return "", nil
	}

	returnedString, _ := returnValues[0].(string)
	returnedError, _ := returnValues[1].(error)

	return returnedString, returnedError
}

func (d CollaboratorDouble) CommandWithNoReturnValues(arg string) {
	d.Call("CommandWithNoReturnValues", arg)
}

func (d CollaboratorDouble) VariadicQuery(args ...string) string {
	returnValues, err := d.Call("VariadicQuery", args)
	if err != nil {
		return ""
	}

	return returnValues[0].(string)
}

type Subject struct {
	collaborator Collaborator
}

func NewSubject(collaborator Collaborator) Subject {
	return Subject{collaborator: collaborator}
}

func (s Subject) DelegateQuery(arg string) string {
	return s.collaborator.Query(arg)
}

func (s Subject) DelegateCommand(arg string) (string, error) {
	return s.collaborator.Command(arg)
}

func (s Subject) DelegateVariadicQuery(args ...string) string {
	return s.collaborator.VariadicQuery(args...)
}

func (s Subject) DelegateCommandWithNoReturnValues(arg string) {
	s.collaborator.CommandWithNoReturnValues(arg)
}

{'fraction_non_alphanumeric': 0.13475870494807574, 'fraction_numerical': 0.002443494196701283, 'mean_word_length': 6.087445887445887, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4685914', 'n_tokens_mistral': 2668, 'n_tokens_neox': 2499, 'n_words': 524}