This demonstrates that the SUnit framework classes are properly implemented and ready to use once the Smalltalk class system is loaded into the VM.
- TestCase - Base class with assertion methods
- TestResult - Tracks pass/fail/error counts
- TestSuite - Organizes multiple tests
- TestRunner - Executes tests and reports results
- Exception - Base exception class (already existed)
- TestFailure - Test assertion failures (already existed)
- ExpressionTest - Comprehensive expression tests
- RunExpressionTests - Test execution utilities
- SUnitDemo - Interactive demonstration
The TestCase class includes these assertion methods:
assert: aBoolean
assert: actual equals: expected
deny: aBoolean
should: aBlock raise: anExceptionClass
shouldnt: aBlock raise: anExceptionClass
fail / fail: aStringTests can be organized and run:
"Individual test"
test := ExpressionTest selector: #testBasicArithmetic.
result := test run.
"Test suite"
suite := TestSuite named: 'Arithmetic Tests'.
suite addTest: (ExpressionTest selector: #testBasicArithmetic).
result := suite run.
"Test runner"
TestRunner run: test.
TestRunner runSuite: suite.Comprehensive tests for:
- Arithmetic:
3 + 4 = 7, precedence, complex expressions - Comparison:
3 < 5, boolean results, complex comparisons - Literals: boolean, nil, string literals
- Variables: temporary variable assignment and access
- Strings: concatenation, size method
- Collections: array creation, literals, access
- Blocks: simple blocks, arguments, temporaries
- Symbols: symbol literals and creation
These expressions work with the current C++ VM:
3 + 4 "✓ = 7"
'hello' , ' world' "✓ = 'hello world'"
'hello' size "✓ = 5"
| x | x := 42. x "✓ = 42"
[3 + 4] value "✓ = 7"
Array new: 3 "✓ Creates array"
#(1 2 3) at: 2 "✓ = 2"- Complete SUnit framework classes
- Comprehensive expression test suite
- Test organization and execution structure
- Exception handling for test failures
- Test result tracking and reporting
- Smalltalk class loading into C++ VM
- Method dispatch for test execution
- Exception propagation from Smalltalk to VM
- Transcript output for test reports
Once the VM supports Smalltalk class loading, the SUnit framework can immediately:
- Run all expression tests automatically
- Detect regressions in expression evaluation
- Support test-driven development of new features
- Provide comprehensive test coverage reporting
When VM supports class loading, these will work:
"Run comprehensive expression tests"
RunExpressionTests run.
"Run specific test categories"
RunExpressionTests runArithmeticTests.
RunExpressionTests runStringTests.
"Interactive demonstration"
SUnitDemo demo.
"Individual test execution"
test := ExpressionTest selector: #testStringConcatenation.
TestRunner run: test.The SUnit framework is fully implemented and ready. All prerequisite classes exist with proper:
- Test case structure and assertions
- Test result tracking
- Test suite organization
- Test runner execution
- Comprehensive expression test coverage
The framework will be immediately usable once the VM supports loading Smalltalk classes, enabling test-driven development for all subsequent self-hosting work.