Exercism exercises in Lua
Install Lua and Luarocks according to the installation instructions for your platform. Then, install all additional development dependencies with:
$ ./bin/install-dev-dependencies
To contribute a patch you will need a GitHub account and you will need to fork
the exercism/lua repo to your account.
Clone your fork with the command: git clone https://github.com/<your_username>/lua
.
Create your patch and open a pull request to the exercism/lua repo.
See the GitHub Help for forking a repo and creating a pull request if you are unfamiliar with this process.
To contribute a new exercise, create a folder named after the exercise within the lua/exercises directory. Create your files for a new test, test class and the implementation.
For example, for the Bob exercise:
$ tree bob
bob
├── bob_spec.lua
└── bob.lua
0 directories, 2 files
Run the test
$ busted
Rename bob.lua to example.lua, and add the exercise to the lua/config.json file.
$ tree bob
bob
├── bob_spec.lua
└── example.lua
0 directories, 2 files
Optionally, you can generate the spec from the upstream canonical data.
To use the spec generator, create a file called spec_generator.lua
in the .meta/
directory of the exercise.
This file should be a Lua module returning a table with two fields:
module_name
- A string containing the name of the Lua variable to which the module under test will be bound.generate_test
- A function that returns a string representation of a test given the corresponding case from the canonical data.
Optionally, a third field can be included:
test_helpers
- A string that will be injected at the top of the outermostdescribe
block. This can include helper functions that are used in multiple tests or other setup code.
To use the test generator, run:
$ ./bin/generate-spec <exercise name>
This will use curl
to fetch the canonical data from the upstream repository, generate the spec file, and format it.
Please be familiar with the contributing guide in the docs repository. This describes some great ways to get involved. In particular, please read the Pull Request Guidelines before opening a pull request.
Pleases see the Useful Lua Resources page.
The Lua icon is inspired by the Lua logo, which was designed by Alexandre Nakonechnyj.