Quick Start - Hello World Example

This is a quick guide to install, compile and run Lumi “hello-world” example in Linux.

Quick Installation

Clone Lumi repository (git clone https://github.com/meircif/lumi-lang.git).

Enter the repository root directory: cd lumi-lang.

Install it: make install.

Hello World Program

hello-world.5.lm
module hello-world

func ! show()
    sys.println(user "hello world")!

main!
    show()!

Compile it: lumi docs/hello-world.5.lm.

Run it:

>>> docs/hello-world
hello world

Hello World Test

hello-world-test.5.lm
module hello-world-test

var Bool println-raise
var String printed-text

mock ! sys.println(user Buffer text)
    if println-raise
        raise! "error in println"
    printed-text.concat(user text)!

test show-hello-world-test()
    println-raise := false
    printed-text.clear()
    hello-world.show()!
    assert! printed-text.equal(user "hello world")

test show-raise-test()
    println-raise := true
    assert-error! hello-world.show(), "error in println"

Compile it: lumi -t hello-world docs/hello-world-test.5.lm docs/hello-world.5.lm.

Run it:

>>> docs/hello-world-test
Running tests:
testing show-hello-world-test... OK
testing show-raise-test... OK
testing code coverage... 100%
Tests passed