Example #1
0
// Insert final newline if needed and indent tabs after internal newlines.
func (self *_Asserter) _LogResult(indent string, result *base.Result) {
	value := result.Value()
	logger := self.logger
	if result.Matched() {
		logger.Logf("%vMATCHED input: %v\n", indent, value)
	} else {
		logger.Logf("%vDID NOT MATCH input: %v\n", indent, value)
	}
	detailsIndent := indent + "\t"
	matcher := result.Matcher()
	if matcher != nil {
		logger.Logf("%vMatcher: %v\n", detailsIndent, matcher)
	}
	logger.Logf("%vBecause: %v\n", detailsIndent, result)
	if matcher != nil {
		for _, comment := range matcher.Comments() {
			logger.Logf("%vComment: %v\n", detailsIndent, comment)
		}
		if causes := result.Causes(); len(causes) > 0 {
			if len(causes) == 1 {
				logger.Logf("%vCauses: (1 cause)\n", detailsIndent)
			} else {
				logger.Logf("%vCauses: (%v causes)\n", detailsIndent, len(causes))
			}
			for _, cause := range result.Causes() {
				self._LogResult(detailsIndent, cause)
			}
		}
		switch w := self.logger.(type) {
		case _Flusher1:
			w.Flush()
		case _Flusher2:
			w.Flush()
		}
	}
}
Example #2
0
func checkResultIsNonMatching(t *testing.T, result *base.Result, message string) {
	if result.Matched() {
		t.Errorf("Expected non-matching result, was [%v] %v", result, message)
	}
}