Porting GNU Smalltalk code to Squeak

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Porting GNU Smalltalk code to Squeak

mcandre
Can someone help me make QuickSmash Squeak-friendly? It's a unit test framework based on QuickCheck.

QuickSmash


Reply | Threaded
Open this post in threaded view
|

Re: Porting GNU Smalltalk code to Squeak

Frank Shearar-3
On 7 August 2011 21:19, Andrew Pennebaker <[hidden email]> wrote:
> Can someone help me make QuickSmash Squeak-friendly? It's a unit test
> framework based on QuickCheck.
> QuickSmash
> https://github.com/mcandre/quicksmash

Ah, you gave up and wrote your own port of cl-quickcheck, then [1]?

If I understand QuickCheck correctly, it's two things:
* assertions / specifications describing correct behaviour;
* a combinator library of random data generators.

The first could probably use SUnit's assert: and friends (which
definitely need some helper methods - I re-implement an
#assert:equals:description in every library I write, just about).

The second will probably need no more help than an easy way to port
gst code to Smalltalk. I'll try and experiment with Coral (which uses
a suspiciously gst-like syntax for its scripts) and see if I can't
hack something up.

TestRunner needs some updating imo: I'd like to see JUnit's Theory
stuff, into which QuickSmash would trivially plug in: with the caveat
that I may have missed the point, QuickSmash sounds to me just like
the Data part of the Theory stuff. (And when we find a failing test
case, we report the case and store the continuation of the test case
allowing an interactive debugging session on the problem! Yay!)

frank

[1] http://stackoverflow.com/questions/6962084/quickcheck-for-smalltalk

Reply | Threaded
Open this post in threaded view
|

Re: Porting GNU Smalltalk code to Squeak

mcandre
SUnit is so integral that it's built into the Smalltalk package manager. But it's a bit redundant to use one unit testing framework's methods in another, no? Also, the current output format tries to match QuickCheck's as closely as possible.

I've used JUnit before, but I'm not sure what "Data and Theory" refer to.

QuickCheck likes to test functions. It works really well in Haskell, even figuring out how to generate the variables to send to the function.

For more information see the Introduction to QuickCheck article.

Cheers,

Andrew Pennebaker

On Sun, Aug 7, 2011 at 5:47 PM, Frank Shearar <[hidden email]> wrote:
On 7 August 2011 21:19, Andrew Pennebaker <[hidden email]> wrote:
> Can someone help me make QuickSmash Squeak-friendly? It's a unit test
> framework based on QuickCheck.
> QuickSmash
> https://github.com/mcandre/quicksmash

Ah, you gave up and wrote your own port of cl-quickcheck, then [1]?

If I understand QuickCheck correctly, it's two things:
* assertions / specifications describing correct behaviour;
* a combinator library of random data generators.

The first could probably use SUnit's assert: and friends (which
definitely need some helper methods - I re-implement an
#assert:equals:description in every library I write, just about).

The second will probably need no more help than an easy way to port
gst code to Smalltalk. I'll try and experiment with Coral (which uses
a suspiciously gst-like syntax for its scripts) and see if I can't
hack something up.

TestRunner needs some updating imo: I'd like to see JUnit's Theory
stuff, into which QuickSmash would trivially plug in: with the caveat
that I may have missed the point, QuickSmash sounds to me just like
the Data part of the Theory stuff. (And when we find a failing test
case, we report the case and store the continuation of the test case
allowing an interactive debugging session on the problem! Yay!)

frank

[1] http://stackoverflow.com/questions/6962084/quickcheck-for-smalltalk




Reply | Threaded
Open this post in threaded view
|

Re: Porting GNU Smalltalk code to Squeak

Frank Shearar-3
On 8 August 2011 00:11, Andrew Pennebaker <[hidden email]> wrote:
> SUnit is so integral that it's built into the Smalltalk package manager. But
> it's a bit redundant to use one unit testing framework's methods in another,
> no? Also, the current output format tries to match QuickCheck's as closely
> as possible.
> I've used JUnit before, but I'm not sure what "Data and Theory" refer to.

It's a few things: a custom test runner, a data generator, and a
specially annotated test (the Theory). The test runner runs the
specially annotated test repeatedly against the data generator. A
theory may also use Assumptions, which basically filter out some data.
For instance,

@RunWith(Theories.class)
public class UserTest {
  @DataPoint public static String GOOD_USERNAME = "optimus";
  @DataPoint public static String USERNAME_WITH_SLASH = "optimus/prime";

  @Theory public void filenameIncludesUsername(String username) {
    assumeThat(username, not(containsString("/")));
    assertThat(new User(username).configFileName(), containsString(username));
  }
}

http://junit.sourceforge.net/doc/ReleaseNotes4.4.html has the full details

My thoughts here are
* extend SUnit to support theories
* plug QuickSmash into SUnit via the data generator stuff for the theories

> QuickCheck likes to test functions. It works really well in Haskell, even
> figuring out how to generate the variables to send to the function.
> For more information see the Introduction to QuickCheck article.
> http://www.haskell.org/haskellwiki/Introduction_to_QuickCheck

Yes, that's the _really_ interesting part about QuickCheck - that you
don't have to set up the data generators yourself; it can use the type
signature of your function to figure all that out automatically.
Without type annotations of some kind, or using a type inference
engine (like Chuck, or RoelTyper), that's not going to happen without
a LOT of work.

frank

> Cheers,
> Andrew Pennebaker
> www.yellosoft.us
> On Sun, Aug 7, 2011 at 5:47 PM, Frank Shearar <[hidden email]>
> wrote:
>>
>> On 7 August 2011 21:19, Andrew Pennebaker <[hidden email]>
>> wrote:
>> > Can someone help me make QuickSmash Squeak-friendly? It's a unit test
>> > framework based on QuickCheck.
>> > QuickSmash
>> > https://github.com/mcandre/quicksmash
>>
>> Ah, you gave up and wrote your own port of cl-quickcheck, then [1]?
>>
>> If I understand QuickCheck correctly, it's two things:
>> * assertions / specifications describing correct behaviour;
>> * a combinator library of random data generators.
>>
>> The first could probably use SUnit's assert: and friends (which
>> definitely need some helper methods - I re-implement an
>> #assert:equals:description in every library I write, just about).
>>
>> The second will probably need no more help than an easy way to port
>> gst code to Smalltalk. I'll try and experiment with Coral (which uses
>> a suspiciously gst-like syntax for its scripts) and see if I can't
>> hack something up.
>>
>> TestRunner needs some updating imo: I'd like to see JUnit's Theory
>> stuff, into which QuickSmash would trivially plug in: with the caveat
>> that I may have missed the point, QuickSmash sounds to me just like
>> the Data part of the Theory stuff. (And when we find a failing test
>> case, we report the case and store the continuation of the test case
>> allowing an interactive debugging session on the problem! Yay!)
>>
>> frank
>>
>> [1] http://stackoverflow.com/questions/6962084/quickcheck-for-smalltalk
>>
>
>
>
>
>