Skip to content

Project 8 - Built-in Unit Testing Framework (grupo 3)#8

Open
agaf2 wants to merge 4 commits into
rbonifacio:mainfrom
agaf2:main
Open

Project 8 - Built-in Unit Testing Framework (grupo 3)#8
agaf2 wants to merge 4 commits into
rbonifacio:mainfrom
agaf2:main

Conversation

@agaf2
Copy link
Copy Markdown

@agaf2 agaf2 commented Apr 22, 2026

Group

  • Alberto Guevara de Araujo Franca
  • Davi Gonzaga Guerreiro Barboza
  • Fábio Pereira de Miranda
  • Felipe Torres de Macedo

This pull request adds a built-in test framework to MiniC, introducing first-class support for test blocks and assertions in the language. It enables writing test blocks with assert statements, running all tests via a new --test command-line flag, and provides type checking and runtime execution for these features. The changes span the parser, AST, type checker, interpreter, CLI, and test suite.

New Language Features:

  • Added assert statements to the language, which evaluate a boolean expression and fail at runtime if the expression is false. [1] [2] [3]
  • Introduced test blocks as top-level items in MiniC programs, allowing users to group assertions under named tests. [1] [2] [3]

Parser and AST Updates:

  • Extended the parser to recognize assert statements and test blocks, and updated the AST to represent these constructs. [1] [2] [3] [4] [5]
  • Updated the reserved word list to include assert and test.

Type Checker Enhancements:

  • Type checker now validates assert statements (requiring a boolean expression) and checks for duplicate test names. It also type-checks the bodies of all test blocks. [1] [2] [3]

Interpreter and CLI Integration:

  • Interpreter can now execute all test blocks using a new run_tests function, with summary output and pass/fail reporting. The CLI supports a --test mode to run all tests in a file. [1] [2] [3]

Test Suite and Fixtures:

  • Added comprehensive tests for assert and test block behavior, including passing, failing, and multiple tests. Added a fixture MiniC file demonstrating the test framework. [1] [2]

These changes collectively introduce a robust, language-integrated test framework for MiniC, improving both developer experience and code reliability.

agaf2 and others added 4 commits April 20, 2026 15:50
Implements test "name" { stmts } top-level blocks, assert expr; statements,
and a --test CLI mode that runs all tests with PASS/FAIL output and a summary.

Co-authored-by: Fábio Miranda <130818362+Fpmiranda7@users.noreply.github.com>
Co-authored-by: Davi Guerreiro <114326602+DaviGGuerreiro@users.noreply.github.com>
feat: Built-in unit testing framework (Project 8)
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