tests for atom (-validation, -watchers, -derefs)

89 views
Skip to first unread message

Linus Ericsson

unread,
Mar 3, 2016, 3:44:42 AM3/3/16
to cloju...@googlegroups.com

while looking into clj-1454 (deref-swap!) and clj-1599 (deref-reset!) I found that there are no test cases for atom.

Since the implementation is straight-forward and is mostly a wrapper of the solid j.u.c.a.AtomicReference this is not very problematic.

However, while addding deref-swap! and deref-reset! there were some code duplication (the deref-* returns the previous, old, changed-from value of the atom) and there is a cognitive overload asserting that validators and watchers actually are in place (I will extend the tests during the weekend, Alex!).

Regardless of wether Rich considers the deref-*s suitable for core in the current form, would there be an interest in tests for

- the various ways to instatiate atoms (with and without validator and metadata)

- that validators throws correctly?

- adding and removing watchers and that they trig as one would expected.

- various ways of changing values (no aim for finding high-load concurrency issues or patological cases or similar).

- that the arities of the interface in IAtom .swap works as expected - ie no reflection warnings (help/pointers for these type of cases needed!)

- generative, tests trying to find yhe glitches while using atoms (the things excluded above).

- performance smoke tests? (this one is hard in uncertain build envitonments, see comments in agent tests)

All of the above suggestions would, åt first, target the current atom implementation, ie not deref-reset! nor deref-swap! (but would be extended to those as well).

/Linus


Alex Miller

unread,
Mar 11, 2016, 3:31:18 PM3/11/16
to Clojure Dev
Yes, would be fine to see an enhancement ticket that adds tests in this area. Generative preferred. Some of these also apply to other stateful constructs too (watchers, validators).  We don't generally include perf tests so I'd leave those out.
Reply all
Reply to author
Forward
0 new messages