Commit details:
- Add unit tests for AST nodes, including Constant, Identifier, UnaryPlus, UnaryMinus, Add, Subtract, Multiply, Divide, and Power.
- Include test cases for evaluating expressions with various node types and operations.
- Introduce a test harness to ensure that each node's `evaluate` method produces the expected results.
- Update the `main` function to use the new `runTests` function when the `--run-tests` option is provided.
- Refactor the existing test function (`runTest`) into individual test functions for better organization and readability.
- Improve the help message to reflect the correct option name (`--run-tests`).
Commit details:
- Added a 'Dependencies' section listing GNU Make and Clang.
- Introduced a 'Running Tests' section with a test expression and corresponding C++ code.
- Demonstrated a complex expression and its expected result.
Commit details:
- Set optimization level to O3 and include pedantic warnings in CXXFLAGS.
- Introduce separate build and source directories for better project organization.
- Add a target to run tests with the ENABLE_TESTS macro.
- Improve the 'all' target to create the build directory before building the executable.
- Introduce a 'rebuild' target for cleaning and rebuilding the project.
Changes made in Makefile:
- Update CXXFLAGS with -O3 and -pedantic.
- Introduce BUILD_DIR and SRC_DIR variables for better organization.
- Modifie SOURCE to point to the source file within the source directory.
- Update EXECUTABLE to exclude the file extension.
- Update 'all' target to create the build directory.
- Add 'test' target to run tests with the ENABLE_TESTS macro.
- Add 'rebuild' target for cleaning and rebuilding the project.
Commit details:
- Add new file ast.cxx with ASTNode, Identifier, Divide, Multiply, Subtract, Power classes.
- Include necessary headers and static initialization of variableTable in Identifier class.
- Add a test function runTest() for evaluating a complex expression.
- Add printHelpMessage() function for displaying program usage.
- Update main function to handle "--run-test" argument.
Commit details:
- Rename main.cxx to src/ast.hxx to better reflect its content.
- Update include statements in the renamed file.
- Remove unnecessary include <cstring> statement from ast.hxx.
- Remove redundant implementation of Power::evaluate() in ast.hxx.
Commit details:
- Refactor the Abstract Syntax Tree (AST) node hierarchy in `main.cxx` for improved memory management and ownership semantics.
- Introduce smart pointers (`std::unique_ptr`) for managing ownership of AST nodes, eliminating manual memory management.
- Add getter functions to access operands in Unary and Binary nodes.
- Implemente functions to release ownership of operands in Unary and Binary nodes.
- Replace manual deletion of operands in the destructor with default virtual destructors for Unary and Binary nodes.
- Add a conditional compilation block (`#ifdef ENABLE_TESTS`) to enable testing functionality.
- Create a test expression in the `runTest` function to evaluate a complex mathematical expression.
- Enable test execution using the `--run-test` command-line option.
- Provide a help message for the main program, outlining available options.