Testing on the MoonScript track

Learn how to test your MoonScript exercises on Exercism


Testing on the MoonScript track is exactly like testing on the Lua track. From an exercise directory, enter:

$ busted

Pending tests

This track follows Exercism's Test-Driven Development methodology. You are given a complete test suite, but only the first test is "active".

To enable the tests, change a test's command from pending to it.

For those of you that like to run all the tests all the time, you can use a command-line tool to change them all at once. Here's an example using perl (which is installed just about everywhere):

$ perl -i -pe 's/^\s+\Kpending\b/it/' two_fer_spec.moon

When you are working in the online editor, the test runner will automatically run all the tests.

Using LuaRocks

Lua by itself is a very small language. LuaRocks is the package manager for Lua modules.

You are free to use any module in your solutions, but not all of them will be available in the online test-runner. The test-runner provides these:

Already available as busted dependencies

  • penlight (home)

    Penlight is a set of pure Lua libraries for making it easier to work with common tasks like iterating over directories, reading configuration files and the like. Provides functional operations on tables and sequences.

  • dkjson (home)

    dkjson is a module for encoding and decoding JSON data.

Already available as MoonScript dependencies

  • LPeg (home)

    LPeg is a new pattern-matching library for Lua, based on Parsing Expression Grammars (PEGs).

  • LuaFileSystem (home)

    LuaFileSystem offers a portable way to access the underlying directory structure and file attributes.

Datetime

  • date (github)

    Date and Time string parsing; Time addition and subtraction; Time span calculation; Supports ISO 8601 Dates.

  • lua-tz (github)

    Lua TZ provides date and time functions with support for time zones. The core functions have an interface similar to the standard functions os.date and os.time, but additionally accept a time zone argument.

  • luatz (github)

    A lua library for time and date manipulation.