Closed jcf closed 7 years ago
As I read this issue back to myself it really does seem like possible-conversions
just doesn't do what I need, and that I should dig into the byte-streams.graph
namespace to extract what I need.
Problem solved!
byte-streams/possible-conversions
does some pretty printing, which means you don't get actual Type
s back.
Using the following modified version of possible-conversions
works as expected:
(defn possible-conversions
[src]
(let [^byte_streams.graph.Type src (byte-streams.graph/type src)
pred (cond
(.type src)
(partial #'byte-streams/converter src)
(= 'seq (.wrapper src))
#'byte-streams/seq-converter
(= 'stream (.wrapper src))
#'byte-streams/stream-converter)]
(->> @byte-streams/conversions
byte-streams.graph/possible-targets
(filter pred))))
Sorry for the noise!
Hello there!
I'm writing a generative test where I'd like to create objects that can be converted to a
ByteArrayInputStream
viabyte-streams/convert
and have come across something unexpected.When I run the following code to convert a
ByteArrayInputStream
into each of the possible conversions I get a lot ofIllegalArgumentExceptions
for seqs, vectors and streams of types.Perhaps I'm misinterpreting the use of possible in
byte-streams/possible-conversions
? Is there a method of getting a list of conversions that will always work? Would filtering out the implicit conversions be enough?The generator in question in case anyone's interested looks like this: