Skip to content

v1.11.0

Compare
Choose a tag to compare
@maxatome maxatome released this 05 Jan 08:32
· 105 commits to master since this release

New features

  • JSON, SubJSONOf and SuperJSONOf operators:
    • Now:
      td.JSON(`{"foo": $1}`, td.Between(12, 34))
      td.JSON(`{"foo": Between($1, $2)}`, 12, 34)
      act the same way. Since v1.10.1 rework, the second was not working as expected.
      At the same time:
      td.JSON(`{"foo": Between(12, 34, $1)}`, td.BoundsOutIn)
      now works as expected. It was rejected before,
    • int_lit & float_lit numbers, as defined in go specification, are now accepted in JSON, allowing, for example, to embed hexadecimal numbers in expected JSON;
  • Between operator accepts time.Duration as TO when FROM is a time.Time;
  • Between, Gt, Gte, Lt and Lte operators:
    • now handle values implementing Compare or Less methods:
      Compare and/or Less methods signatures follow:
      func (a T) Less(b T) bool   // returns true if a < b
      func (a T) Compare(b T) int // returns -1 if a < b, 1 if a > b, 0 if a == b
      for example, the new go1.18 net/netip.Addr implements both,
    • failure reports display numbers as elsewhere,
    • some docs have been fixed;
  • Smuggle can now cast values, allowing such things:
    // A string containing JSON
    got := `{ "foo": 123 }`
    td.Cmp(t, got, td.Smuggle(json.RawMessage{}, td.JSON(`{"foo":123}`))
    // or
    td.Cmp(t, got, td.Smuggle((json.RawMessage)(nil), td.JSON(`{"foo":123}`))
  • in report failures, the stack trace was displayed if it contained at least 2 levels. Now it is also displayed if it contains one level BUT the source file path contains a directory. It helps to localize quickly the errors in large repositories;
  • td.T gains 3 new methods to log with a stack trace: LogTrace, ErrorTrace and FatalTrace;
  • handle go1.17 []T*[n]T convertibility edge case;
  • in failure reports (float64) type is now omitted (like (int) and (bool) already were), but the value always contains a "." (except if ±Inf, NaN or with exponent) to distinguish them from int.

Fixes

  • Contains: slice in slice search didn't work at end of slice;
  • JSON, SubJSONOf and SuperJSONOf operators panicked when using All+JSON-operator+embeddedOp+$1;
  • anchoring 2 slices at the same time didn't work.

Miscellaneous

And happy new year!