Skip to content
heuermh edited this page Sep 13, 2010 · 18 revisions

Welcome to the lick wiki!

User documentation

To include LiCK in your own ChucK scripts:


$ chuck --loop &

$ chuck + import.ck
...
"LiCK imported." : (string)

$ chuck + my-script.ck

Currently, the best place to look for user documentation is in the unit test classes (e.g. ArrayListTest.ck demonstrates how to use ArrayList.ck).

Developer documentation

Contributing to LiCK

LiCK is welcome to any contributions! Don’t worry too much about style or formatting, that can all be worked out later.

Please add the license header (HEADER.txt) to the top of each file and provide an author statement if you wish.

If you add classes to LiCK, be sure to update import.ck with the new classes and their dependencies in the correct order. If you have unit tests for those classes, be sure to update tests.ck with the new unit tests.

Any suggestions as to where examples should live are also welcome.

Design considerations

ChucK doesn’t provide interfaces or explicit abstract classes, so LiCK uses empty or no-op classes to represent those concepts. For example, List.ck really aught to be an interface that ArrayList.ck and LinkedList.ck would implement. In LiCK, List.ck is a class with empty or no-op implementations of all its methods which are then overridden by ArrayList.ck.

There are a lot of small classes in LiCK, by design. Simplified access to all these small classes is provided by static methods (e.g. Loops.ck provides static methods that create and return instances of Loop.ck or Repeat.ck).

How to write unit tests

ChucK doesn’t allow calling methods via reflection, so unit tests in LiCK should follow the pattern described below to be executed properly.

Each unit test should be a class which extends Assert.ck


class MyUnitTest extends Assert
{
}

Next, provide test methods that utilize assertXxx methods to make assertions about the class under test. Assertion messages are optional.


class MyUnitTest extends Assert
{

  fun void testFoo()
  {
    assertTrue("this should be true", true);
  }

  fun void testBar()
  {
    assertFalse("this should be false", false);
  }
}

Provide an pseudo-constructor method that sets exitOnFailure as desired, calls each of the testXxx methods, and prints out a message to stdout on success


class MyUnitTest extends Assert
{
  {
    true => exitOnFailure;
    testFoo();
    testBar();
    <<<"MyUnitTest ok">>>;
  }

  fun void testFoo()
  {
    assertTrue("this should be true", true);
  }

  fun void testBar()
  {
    assertFalse("this should be false", false);
  }
}

Finally, instantiate the unit test and allow ChucK time to pass.


class MyUnitTest extends Assert
{
  {
    true => exitOnFailure;
    testFoo();
    testBar();
    <<<"MyUnitTest ok">>>;
  }

  fun void testFoo()
  {
    assertTrue("this should be true", true);
  }

  fun void testBar()
  {
    assertFalse("this should be false", false);
  }
}

MyUnitTest myUnitTest;
1::second => now;

See http://www.junit.org for further documentation on assertions and unit testing in general.

Clone this wiki locally