Projeto completo: calculadora modular
Estrutura:
calculator/
├── nova.toml
├── main.nova
├── arithmetic.nova
└── arithmetic_test.nova
arithmetic.nova:
pub fn add(a: int, b: int) -> int { return a + b; }
pub fn multiply(a: int, b: int) -> int { return a * b; }
main.nova:
import arithmetic::add;
import arithmetic::multiply;
fn main() -> void {
let subtotal = add(20, 10);
let total = multiply(subtotal, 2);
print(total);
}
arithmetic_test.nova:
import arithmetic::add;
import arithmetic::multiply;
fn test_add() -> void { assert_eq(add(2, 3), 5); }
fn test_multiply() -> void { assert_eq(multiply(6, 7), 42); }
Execute o ciclo:
nova fmt .
nova lint . --deny-warnings
nova check .
nova test .
nova run .
nova build .
Esse projeto usa somente o núcleo pretendido para a alpha: funções, tipos primitivos, bindings, aritmética, imports locais e testes.