[chuck-users] parent and children classes (I meant polymorphism)

mike clemow gelfmuse at gmail.com
Wed Jan 21 16:15:13 EST 2009


Michael,

Hrm...  Yes, you're right; we've gone over this before.  How do you
represent objects in your ArrayList class?  Are you using arrays?  If
yes, how do you avoid the issues that are brought to the surface by my
code?  I'd be surprised if you haven't run into the issues with Arrays
of Objects that Kassen is talking about.

-Mike

On Wed, Jan 21, 2009 at 3:46 PM, Michael Heuer <heuermh at gmail.com> wrote:
> mike clemow wrote:
>
>> // this doesn't work...
>> //myCollection.pop() $ Event @=> Event f;
>
> Are you sure that doesn't work?  I swear I have been doing the same
> with my collection classes.
>
> >From ArrayListTest.ck:
>
> class Foo
> {
>    fun int foo()
>    {
>        return 1;
>    }
> }
>
> // unit test for ArrayList
>
> class ArrayListTest extends Assert
> {
>    {
>        true => exitOnFailure;
>        testConstructor();
>        testSize();
>        testGetAddSet();
>        testIterator();
>        testForEach();
>        testAssign();
>        testTransform();
>        testAddAll();
>        testFoo();
>
>        <<<"ArrayListTest ok">>>;
>    }
>
> //...
>
>    fun void testFoo()
>    {
>        ArrayList list;
>        Foo fooIn;
>        list.add(fooIn);
>        list.get(0) $ Foo @=> Foo fooOut;
>        assertEquals(fooIn, fooOut);
>        <<<fooOut.foo()>>>;
>    }
> }
>
> ...
> [chuck](VM): sporking incoming shred: 1 (ArrayListTest.ck)...
> 1 :(int)
> "ArrayListTest ok" : (string)
>
>   michael
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>



-- 
http://michaelclemow.com
http://semiotech.org


More information about the chuck-users mailing list