Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kikito/lua_missions
Lua Koans, minus the Zen stuff
https://github.com/kikito/lua_missions
Last synced: 3 days ago
JSON representation
Lua Koans, minus the Zen stuff
- Host: GitHub
- URL: https://github.com/kikito/lua_missions
- Owner: kikito
- Created: 2011-06-01T22:38:49.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2024-06-08T17:54:21.000Z (8 months ago)
- Last Synced: 2025-01-25T21:07:24.369Z (10 days ago)
- Language: Lua
- Homepage: https://github.com/kikito/lua_missions
- Size: 109 KB
- Stars: 384
- Watchers: 17
- Forks: 77
- Open Issues: 4
-
Metadata Files:
- Readme: README.rdoc
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
- awesome-by-example - Lua Missions: Lua Koans, minus the Zen stuff
- awesome-defold - Lua Missions
README
= Lua Missions
{}[https://travis-ci.org/kikito/lua_missions]
The Lua Missions help you learn Lua.
The goal is to learn the Lua language, syntax, structure, and some common
functions and libraries, through failing tests.== The Structure
The lessons are broken out into areas by file, strings are covered in strings.lua,
functions are covered in functions.lua, etc. They are presented in order in the
missions.lua file.Each mission builds up your knowledge of Lua and builds upon itself. It will stop at
the first place you need to correct.Some missions simply need to have the correct answer substituted for an incorrect one.
Some, however, require you to supply your own answer. If you see the variable +__+ (a
double underscore) listed, it is a hint to you to supply your own code in order to
make it work correctly.== Installing Lua
If you do not have Lua setup, please visit http://www.lua.org/download.html for
operating specific instructions. To check the installations simply type:*nix platforms from any terminal window:
[~] $ lua -v
Windows from the command prompt (cmd.exe)
c:\lua -v
The output should include the version of Lua that is in your path. These missions are tested
in Lua 5.1.x, 5.2.x, Lua 5.3.x, Lua 5.4.x and LuaJIT.== The Missions
In order to run the tests, you must execute the missions.lua file.
*nix platforms, from the lua_missions/missions directory:
[lua_missions] $ cd missions
[lua_missions/missions] $ lua missions.luaWindows is the same thing
c:\> cd lua_missions\missions
c:\lua_missions\missions\> lua missions.lua=== Red, Green, Refactor
In test-driven development the process has always been, red, green, refactor. Write a
failing test and run it (red), make the test pass (green), then refactor it (that is
look at the code and see if you can make it any better. In this case you will need
to run the mission and see it fail (red), make the test pass (green), then take a
moment and reflect upon the test and improve the code to better communicate its intent (refactor).The very first time you run it you will see the following output:
[lua_missions] $ cd missions
[lua_missions/missions] $ lua missions.lua
(in /Users/person/dev/lua_missions)F
*** Mission status ***
asserts...........................................[Incomplete]
test_assert: [fail]
Assertion failed: Expected [false] to be [true]
The error happened here:
asserts.lua:3: in functionIt is telling you where to look for the first solution:
Assertion failed: Expected [false] to be [true]
The error happened here:
asserts.lua:3: in functionWe then open up the asserts.lua file and look at the first test:
function test_assert()
assert_true(false) -- this should be true
endWe then change the +false+ to +true+ and run the test again. Ignore everything except
the method name (+test_assert+) and the parts inside the method (everything
before the +end+).In this case the goal is for you to see that if you pass a value to the +assert+
method, it will either ensure it is +true+ and continue on, or fail if in fact
the statement is +false+.== Inspiration
This is heavily inspired by the Ruby Koans project:
http://rubykoans.com/
Go there and check it out, in case you are curious about ruby. Ruby is a great language and the Ruby Koans are a great way to learn it.
== Other Resources
The Lua Language :: http://www.lua.org
Programming in lua :: http://www.lua.org/pil
Lua-users wiki :: http://lua-users.org/= Other stuff
Author :: Enrique García
Source & Issues:: http://www.github.com/kikito/lua_missions
Requires :: Lua >= 5.1 (optional: Rake for building up the files from source)= License
http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png
lua_missions is released under a Creative Commons,
Attribution-NonCommercial-ShareAlike, Version 3.0
(http://creativecommons.org/licenses/by-nc-sa/3.0/) License.