jubilo.lua – A tiny, functional lua testing framework

I have been needing to do some more testing of my coronaSDK apps. Things tend to break, and I have to go dig and find them…

…not any more. I decided to build myself a nice little utility to handle testing in my projects. jubilo.lua was born.

I built jubilo in lua to be compatible with all lua applications and not specific to corona. It would be cool to be featured on this page someday too.

jubilo.lua is small, exactly 150 lines of code as of today. It has everything needed to test lua applications. It has only one type of test, assertion. The print formatting is very slick (and adjustable).

Here is the full feature list:

  • assert function (this only tests if a condition is true of false. It’s all a test framework really needs)
  • nested contexts
  • adjustable print formatting
  • result summary (via the run() function)
  • optional “no conflict mode” (forces the library to run in a namespace)

jubilo.lua was inspired by telescope. I even borrowed some documentation as a sort of tribute. My design was to make jubilo look like and function similar to telescope, but stripped of all unnecessary features. These features are all good, but I left out everything that didn’t take away from testing at its core. For example, jubilo.lua only has one type of assertion.

There is one addition I made to jubilo.lua in formatting. telescope only prints results for tests:

-- taken from telescope's documentation
------------------------------------------------------------------------
A context:
A nested context:
  A test                                                             [P]
  Another nested context:
    Another test                                                     [P]
A test in the top-level context                                      [F]
------------------------------------------------------------------------

jubilo.lua fails all contexts that have failing tests:

-- taken from jubilo.lua's documentation
----------------------------------------------------------------------
A context:                                                         [f]
  A nested context:                                                [p]
    A test                                                         [p]
    Another nested context:                                        [p]
      Another test                                                 [p]
  A test in the top-level context                                  [f]
----------------------------------------------------------------------

Why the name “jubilo”? “lua” is Portuguese for “moon”. “júbilo” is Portuguese for “joy”. There you go, a joyful testing library.

Please check out the code on github here. I will be adding updates there. Hopefully I will get around to testing jubilo.lua against itself. I am also going to try to write a comprehensive tutorial on jubilo. For now, please read the documentation.

Enjoy!

Example of jubilo.lua's full result formatting.

 

I Heart CoronaSDK

A week ago, anscamobile announced a video contest for their coronaSDK. The following project is my submission:

The goal of the iheartcoronasdk.com website is to gather the stories of the developers using, well… coronaSDK. Because all of the games I have created with corona are in development still, I thought it would be best to create a story for the video instead of telling a story.

So, I set off to make a game in ten minutes… Why? Corona has been called fast by developers. It ramps up development speed and turns ideas into games before the ideas fade. I wanted to prove it.

I came up with a simple idea which draws some inspiration from ninjump, the popular iPhone/iPad game. In my idea, two guns/cannons on either side of the screen share one bullet. This must be used to pop falling balloons. Since there is single bullet, the guns must catch the bullet in order to reuse it.

So I need to get my idea working. I need it working so I can see it. I need it working so my artist can see it. I need it working so I can explain it better to my team. How quickly can I turn my concept into a proof of concept with corona?

I drew a circle and a rectangle to resemble a gun. I set up a basic corona project, pressed record, and started working. There was no practice, I just started working. Can I build a game in ten minutes?

…sort of. It turns out that ten minutes is not as long as one might think. Having a ten minute deadline tends to make you think less clearly as well. On the video, I troubleshoot for 30 seconds or so because my “baloon” won’t show up. Oh wait, it’s balloon with to l’s. (Btw, I’m using a balloon image to represent a bullet because it was what I had) Anyway, by the end of ten minutes, I just barely got the balloon to fly across the screen from cannon to cannon.

I’m going to take a second to dissect that. In ten minutes, I created and displayed three images. I positioned, scaled, and rotated them all. I enabled a full-featured physics engine and attached physics properties to my balloon. Gravity is working great, I also added an impulse to get the balloon to move horizontally. All of this in ten minutes… with no script… no do-overs… On how many game platforms can you do that? I wouldn’t even be drawing anything yet if I were writing Obj-C.

Since I wasn’t quite where I wanted to be, I spent another ten. Still not quite functional. After 30 minutes total, I was satisfied with my demo. By that time I had added user interaction. Tapping the screen launches a balloon. I added animation. The cannons slide and rotate on queue. I also had added collision detection. The balloon recognizes when it is in contact with the cannon and updates the game accordingly.

I realize the game doesn’t look like much, but it represents the power of corona for game development. In thirty minutes I developed a game that used all of the features a game might need. On top of everything, I have never developed an iPad game with corona before. I developed this game solely for the iPad. There was no learning curve, it just worked.

So with all of this said, go check out corona if you haven’t already. Otherwise go say thank you to the ansca staff by making a video about your experience: http://www.iheartcoronasdk.com/

Gesture Library Teaser

Over the past few weeks, I have been working on a library for the upcoming Titanium Marketplace. Appcelerator has been planning a marketplace for developers to release code assets and native extensions for their platform for a year. With the launch of the store imminent, I thought I would put up a few samples of my library, which has been approved for the marketplace beta.

What is it? My library takes a set of points (usually from user input), and matches them with a gesture. More simply, it quickly and accurately decides if the user has drawn a circle, a rectangle, a triangle, etc.

I’ll defer to the sample video I made (HD is available in youtube):

It’s got a poster too!

List of features:
- Quickly and accurately recognizes touch screen gestures.
- Define your own custom gestures.
- Rotation and scale independent.
- Flexible: The library matches gestures based upon a set of points. Input other than the touch screen could be recognized.

Titanium Gesture Library… coming soon to the Titanium Marketplace!