Files
metabuilder/mojo/samples/examples/testing
johndoe6345789 83f1533bce feat(mojo): integrate Modular Mojo compiler implementation
Extracted from modular repo and reorganized:

Compiler Implementation:
- 21 compiler source files (frontend, semantic, IR, codegen, runtime)
- 15 comprehensive test files (lexer, parser, type checker, backend, etc.)
- 9 compiler usage example programs

Architecture (5 phases):
- Frontend: Lexer, parser, AST generation (lexer.mojo, parser.mojo, ast.mojo)
- Semantic: Type system, checking, symbol resolution (3 files)
- IR: MLIR code generation (mlir_gen.mojo, mojo_dialect.mojo)
- Codegen: LLVM backend, optimization passes (llvm_backend.mojo, optimizer.mojo)
- Runtime: Memory mgmt, reflection, async support (3 files)

File Organization:
- mojo/compiler/src/: Compiler implementation (21 files, 952K)
- mojo/compiler/tests/: Test suite (15 files)
- mojo/compiler/examples/: Usage examples (9 files)
- mojo/samples/: Mojo language examples (37 files, moved from examples/)

Documentation:
- mojo/CLAUDE.md: Project-level guide
- mojo/compiler/CLAUDE.md: Detailed architecture documentation
- mojo/compiler/README.md: Quick start guide
- mojo/samples/README.md: Example programs guide

Status:
- Compiler architecture complete (Phase 4)
- Full test coverage included
- Ready for continued development and integration

Files tracked:
- 45 new compiler files (21 src + 15 tests + 9 examples)
- 1 moved existing directory (examples → samples)
- 3 documentation files created
- 1 root CLAUDE.md updated

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-23 19:05:44 +00:00
..

Modular testing framework examples

This directory contains examples of using the Mojo testing framework for unit testing. See the Testing section of the Mojo manual for a complete discussion of how to use the Mojo testing framework.

Files

This directory contains the following files:

  • src/my_math/__init__.mojo: a Mojo package file

  • src/my_math/utils.mojo: a Mojo module source file

  • src/example.mojo: a simple Mojo program that uses the functions from the my_math package

  • test/my_math/test_*.mojo: Mojo test files containing unit tests for functions defined in the my_math package

  • pixi.toml: a Pixi project file containing the project dependencies and task definitions.

Run the code

This example project uses the Pixi package and virtual environment manager.

Once you have installed pixi, activate the project's virtual environment by navigating to the project's root directory and executing:

pixi shell

Run the unit tests contained in the test directory by executing:

mojo run test/my_math/test_dec.mojo
mojo run test/my_math/test_inc.mojo

If desired, you can run the example program by executing:

mojo src/example.mojo

Once you're done, deactivate the project's virtual environment by executing:

exit