Skip to content

Conversation

@oyamo
Copy link

@oyamo oyamo commented Jan 18, 2026

This PR integrates a dedicated testing feature into the Language. It enables developers to write unit tests using the pima module

Features

  1. Test module (pima)
  2. Assertion function (pima.hakiki)

Usage requirements

  1. Import the module using the import directive tumia pima to access the pima.hakiki assertion function.
  2. Create functions with prefix pima_ inorder to register tests,
  3. Use assertion function pima.hakiki(condition, message) to validate your logic
    ** condition: An expression that evaluates to true or false.
    ** message: A string describing the error if the assertion fails.

How to Run Tests (Jinsi ya Kuendesha)

The test runner is built directly into the Nuru CLI:

nuru pima <filename>

Example usage

tumia pima;

unda pima_kujumlisha() {
    pima.hakiki(1 + 1 == 2, "Hesabu ni sahihi");
}

unda pima_itafeli() {
    pima.hakiki(1 == 5, "Hii inafeli");
}

CLI Output

============================= JARIBIO LIMEANZA =============================
imekusanya vipengele 2

pima_kujumlisha                IMEFAULU
pima_itafeli                   IMEFELI

========================= MAJARIBIO YALIYOSHINDWA ==========================
_________________________ pima_itafeli _________________________
>   Hii inafeli

IMESHINDWA
hali ya kutoka 1
IMESHINDWA	kuu	0.001s

Checklist

  • Syntax errors halt execution immediately.
  • Returns exit code 1 on failure
  • Output routed correctly to stdout and stderr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant