Test Suite Overview
Purpose
This comprehensive test suite ensures consistent behavior across all TON implementations. Each test category validates specific aspects of the TON specification, providing clear input/output expectations that can be replicated in any programming language.
Test Categories
1. Lexer Tests
Validates tokenization of TON source text into discrete tokens.
- Focus: Character stream to token stream conversion
- Coverage: All token types, escape sequences, comments, position tracking
- View Lexer Test Specifications →
2. Parser Tests
Validates construction of abstract syntax tree from tokens.
- Focus: Syntactic structure validation and object model creation
- Coverage: Object structures, properties, nested objects, all data types
- View Parser Test Specifications →
3. Serializer Tests
Validates conversion of object model back to TON text format.
- Focus: Object to text conversion with formatting options
- Coverage: Compact/pretty formatting, escaping, round-trip consistency
- View Serializer Test Specifications →
4. Validator Tests
Validates schema enforcement and constraint checking.
- Focus: Schema validation, type checking, constraint enforcement
- Coverage: Required fields, type validation, custom rules, path-based validation
- View Validator Test Specifications →
5. Array Tests
Validates array parsing, serialization, and validation.
- Focus: Array-specific functionality
- Coverage: Empty arrays, mixed types, nested arrays, validation rules
- View Array Test Specifications →
6. Edge Case Tests
Validates handling of boundary conditions and error scenarios.
- Focus: Error handling and edge conditions
- Coverage: Invalid input, extreme values, special characters, error recovery
- View Edge Case Test Specifications →
7. Integration Tests
End-to-end testing of complete workflows and component interactions.
- Focus: Full system integration and round-trip operations
- Coverage: File I/O, streaming, object conversion, external schemas
- View Integration Test Specifications →
8. Multi-line String Tests
Tests for triple-quoted multi-line string literals and indentation handling.
- Focus: Multi-line string parsing and formatting
- Coverage: Triple quotes, indentation processing, escape sequences
- View Multi-line String Test Specifications →
9. Path-Based Schema Tests
Validation of path-based property schemas and nested validation rules.
- Focus: Path resolution and schema application
- Coverage: Deep paths, wildcards, array indices, class scoping
- View Path-Based Schema Test Specifications →
10. Formatter Tests
Document formatting and style transformation capabilities.
- Focus: Pretty and compact formatting styles
- Coverage: Indentation, type hints, headers, comment preservation
- View Formatter Test Specifications →
11. Numeric Property Tests
Handling of numeric and alphanumeric property names.
- Focus: Properties with numeric names or starting with numbers
- Coverage: Pure numbers, years, mixed names, floating point notation
- View Numeric Property Test Specifications →
Test Structure Format
Each test specification follows this consistent format:
Test ID: [Category]_[TestNumber]
Test Name: [Descriptive name]
Purpose: [What aspect is being tested]
Input:
[Exact TON input or object structure]
Expected Output/Behavior:
[Exact expected result or behavior]
Validation Points:
- [Specific assertion 1]
- [Specific assertion 2]
- [etc.]
Implementation Guidelines
For Test Implementers
- Exact Replication: Test inputs and expected outputs must be replicated exactly as specified
- No Assumptions: Do not make assumptions about behavior not explicitly stated
- Complete Coverage: All test cases in a category must be implemented
- Clear Reporting: Test failures should clearly indicate which specification was not met
Test Execution Order
While tests should be independent, the recommended execution order is:
- Lexer Tests (foundational)
- Parser Tests (builds on lexer)
- Multi-line String Tests (lexer feature)
- Numeric Property Tests (parser feature)
- Array Tests (specific feature)
- Serializer Tests (validates output)
- Formatter Tests (formatting styles)
- Validator Tests (schema enforcement)
- Path-Based Schema Tests (advanced validation)
- Edge Case Tests (error handling)
- Integration Tests (end-to-end)
Conformance Levels
Tests are grouped by conformance level:
- Level 1 (Basic): Core functionality tests
- Level 2 (Standard): Complete literal and type support
- Level 3 (Full): All features including advanced validation
See Conformance Levels for detailed requirements.