tuura / plato

A DSL for asynchronous circuits specification
Other
12 stars 2 forks source link

Tests 2 #7

Closed mvdan closed 8 years ago

mvdan commented 8 years ago

Just a continuation of what I began yesterday. Also with a slight simplification to keep test bodies smaller.

@snowleopard a few questions:

snowleopard commented 8 years ago

I decided to merge and then do quite a bit of refactoring. Should be complete today.

snowleopard commented 8 years ago

@mvdan Answering some of your questions:

mvdan commented 8 years ago

More generally, we can probably switch to the following type: type Signal = Int during testing, so we don't have to bother with choosing names.

SGTM

We can try to rely on QuickCheck for automatically testing with different initial states.

Can you make sure that the important bits are covered then, though? From what I can see quickcheck is like fuzzy testing. Which is good and can be part of CI, but manual specific tests should still be there.

We could turn simulation into a monad and then we won't have to explicitly carry around the current state of a circuit under simulation.

My haskell falls a bit short here, so I'll look closely at your code if you do this :)

snowleopard commented 8 years ago

From what I can see quickcheck is like fuzzy testing. Which is good and can be part of CI, but manual specific tests should still be there.

Yes, that's right. The standard pattern is: several custom tests, plus a bunch of general properties that are checked by QuickCheck and often become part of documentation.

snowleopard commented 8 years ago

@mvdan Have a look at how I reworked tests & associated concepts infrastructure.

mvdan commented 8 years ago

We can now use Simulation monad for building and composing interesting simulations without explicitly passing the state around. PureSimulation should be used when we don't need to run the simulation inside any other monad. In Test we do need to run the simulation inside the IO monad as we need to write a test log. Same for Main, but in general I hope we'll find PureSimulation useful.

Cool, thanks!

Regarding the A | B | C issue: simply use the silent concept to shut up unused signals.

OK.

You might also like how I modified the initial state in the inverter test: initialState = State $ (== B).

Damn, that's clever. Everything that came to my mind was way longer.

Also, isn't the $ redundant?

snowleopard commented 8 years ago

Also, isn't the $ redundant?

You are right! Fixed now :-)