Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

[tests] Use the EDN matcher for testing transaction output #271

@ncalexan

Description

@ncalexan

In #214, I implemented the first parts of #188, which tracks converting Clojure implementation tests into generic EDN format tests that could run against the Clojure implementation and the Rust Mentat implementation.

As I say in #188:

It might be finicky to get the transaction IDs, timestamps, and other ephemeral data correct. I wonder if we can rewrite :db/tx and :db/txInstant in controlled locations to get what we want?

And that's what I did in #214: I translated transaction IDs and certain timestamps into edn::Value::Symbol instances like ?txN and ?msN, and then compared the resulting EDN with test EDN using the same symbols. That is, after reading from the store I post-processed the transaction assertions and datom assertions, etc, looking for particular patterns and combinations to rewrite.

This ticket tracks doing something more general. I'd like to be able to take arbitrary EDN and pattern match it against EDN, without having to postprocess. I want to handle a few things:

  • _ matches arbitrary sub-EDN;
  • ?name matches sub-EDN, which must be identical each place ?name appears;
  • ... matches arbitrary sibling-EDN

For example:

  • [_] matches an arbitrary one-element vector
  • [_ _]matches an arbitrary two-element vector
  • [?x ?x] matches [1 1] and [#{} #{}] but not [1 2] or [[] #{}]
  • [1 ...] matches [1] and [1 1] and [1 2 3], but not [2] or [2 1] or #{1 2}.

Note that ... is a valid EDN symbol. Sibling EDN is a little tricky because it needs to handle un-ordered sets and maps, but I think it's do-able.

This is a particularly useful case of a structural EDN differ, as discussed in #220.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions