Integration Test Specifications

End-to-end integration tests that verify complete workflows and component interactions.

Test Case: INTEGRATION_001 - Round-Trip Complex Document

Purpose

Test that a complex document can be parsed, serialized, and re-parsed without data loss.

Input

#@ tonVersion = '1', @schemaFile = 'schema.ton'

{(database)
    @host = $'localhost',
    @port = %5432,
    name = 'mydb',
    ssl = true,
    maxConnections = 0xFF,
    flags = 0b11010101,
    instanceId = 550e8400-e29b-41d4-a716-446655440000,
    logLevel = |debug|,
    features = |encryption|compression|monitoring|,
    createdAt = '2024-01-15T10:30:00Z',
    lastBackup = null,
    description = undefined,

    {(credentials)
        username = 'admin',
        password = 'secret123',
        expires = '2024-12-31T23:59:59Z'
    },

    {(pool)
        min = 5,
        max = 100,
        timeout = 30
    }
}

Expected Result

  • Parse original document successfully
  • Serialize to string format
  • Parse serialized string
  • All data values preserved exactly
  • Header metadata intact
  • Schema definitions maintained

Validation Points

  • Header tonVersion = "1"
  • Header schemaFile = "schema.ton"
  • Root class name = "database"
  • Property host = "localhost"
  • Property port = 5432
  • Property maxConnections = 255 (0xFF)
  • Property flags = 213 (0b11010101)
  • GUID preserved exactly
  • Enum and EnumSet values intact
  • Child objects maintained

Test Case: INTEGRATION_002 - File Operations

Purpose

Test reading from and writing to files with proper encoding and formatting.

Input

{
    name = 'Test File',
    version = 1.0,
    active = true
}

Operations

  1. Write content to file "test.ton"
  2. Parse file from disk
  3. Modify document (add properties)
  4. Save to new file "output.ton"
  5. Read and verify output file

Expected Result

  • File source tracked correctly
  • Properties parsed accurately
  • Modifications applied successfully
  • Output file contains updated content
  • Type hints preserved in output

Test Case: INTEGRATION_003 - Stream Operations

Purpose

Test parsing from and serializing to streams for efficient memory usage.

Input

{
    data = 'stream test',
    value = 42
}

Operations

  1. Create memory stream with UTF-8 encoded content
  2. Parse document from stream
  3. Serialize document to output stream
  4. Read result from output stream

Expected Result

  • Parse from stream successful
  • All properties preserved
  • Serialization to stream works
  • Output contains all original data
  • UTF-8 encoding maintained

Test Case: INTEGRATION_004 - Object Conversion

Purpose

Test conversion between native objects and TON documents.

Test Object Structure

// Example object structure (language-agnostic representation)
TestData {
    Id: GUID,
    Name: string,
    Count: integer,
    IsActive: boolean,
    Tags: array of strings,
    CreatedAt: datetime,
    Metadata: {
        Version: string,
        Author: string
    }
}

Operations

  1. Create native object with test data
  2. Convert object to TON document
  3. Serialize to TON string
  4. Parse TON string back
  5. Convert to native object

Expected Result

  • Object properties mapped correctly
  • Nested objects preserved
  • Arrays converted properly
  • Type conversions accurate
  • Round-trip preserves all data

Test Case: INTEGRATION_005 - External Schema Validation

Purpose

Test loading and applying external schema files for validation.

Schema File Content

#! enum(priority) [low, medium, high, critical]

#! {(task)
    /title = string(required, minLength(1), maxLength(100)),
    /description = string(maxLength(500)),
    /priority = enum:priority(required, default(medium)),
    /completed = boolean(default(false)),
    /dueDate = date(future)
}

Document Content

#@ @schemaFile = 'schema.ton'

{(task)
    title = 'Complete unit tests',
    description = 'Write comprehensive unit tests for TON parser',
    priority = |high|,
    completed = false,
    dueDate = '2024-12-31T23:59:59Z'
}

Expected Result

  • Schema file path resolved correctly
  • Schema definitions loaded
  • Validation rules applied
  • Enum values validated
  • Default values applied where needed

Test Case: INTEGRATION_006 - Large Document Handling

Purpose

Test performance and correctness with large documents.

Test Parameters

  • 1000 properties in root object
  • 100 child objects
  • 10 properties per child
  • Total: 2000+ properties

Operations

  1. Create document programmatically
  2. Add 1000 properties to root
  3. Add 100 child objects
  4. Serialize to string
  5. Parse back and verify

Expected Result

  • Document created successfully
  • Serialization completes
  • Parsing handles large input
  • All properties preserved
  • Performance acceptable (<1 second)

Implementation Notes

  • Use temporary directories for file operations
  • Clean up test files after completion
  • Test both synchronous and asynchronous operations
  • Verify UTF-8 encoding in all file operations
  • Test cross-platform path handling

Error Scenarios

  • File not found during read operations
  • Permission denied for write operations
  • Invalid encoding in stream operations
  • Schema file not found or invalid
  • Memory constraints with large documents