Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

readme.md

DixScript Console Application - Test System

Overview

The DixScript Console Application now includes a comprehensive test file system with three levels of complexity: Basic, Intermediate, and Advanced. Each level tests different features of the DixScript language and processing pipeline.

Project Structure

DixScriptConsoleApp/
├── Program.cs                    # Main entry point with test selection
├── TestScenario.cs              # Enum defining test scenarios
├── TestRunner.cs                # Test execution and performance utilities
├── TestFiles/
│   ├── BasicTest.cs             # Basic DixScript test cases
│   ├── IntermediateTest.cs      # Intermediate test cases with enums
│   └── AdvancedTest.cs          # Advanced tests with functions & events
└── DixScriptConsoleApp.csproj   # Updated project file

Test Scenarios

🟢 Basic Tests (TestScenario.Basic)

  • Features: @CONFIG, @DLM, simple @DATA sections
  • Focus: Fundamental parsing, basic data structures, table/group syntax
  • Test Cases:
    • SimpleConfig - Basic configuration and data structures
    • TableSyntax - Table/group syntax testing (27% more compact than TOML)
    • DataTypes - Various data types, hex colors, prefixed constructors
    • ErrorHandling - Parser resilience with intentional syntax errors

🟡 Intermediate Tests (TestScenario.Intermediate)

  • Features: All basic features plus @ENUMS and advanced @DATA
  • Focus: Enum usage, complex data structures, configuration management
  • Test Cases:
    • EnumUsage - Enums with value assignments and usage in data
    • ComplexData - Nested objects, arrays, complex inventory systems
    • Configuration - Multi-environment configuration with database settings

🔴 Advanced Tests (TestScenario.Advanced)

  • Features: All sections including @QUICKFUNCS and @EVENTS
  • Focus: Function scoping, built-in registry system, event handling
  • Test Cases:
    • CompleteFeature - Full language capabilities with functions and events
    • FunctionScoping - Advanced function scoping and data manipulation
    • BuiltinSystem - Registry-based built-in system testing

Usage

Command Line Interface

# Run default test (Basic scenario, first test case)
dotnet run

# Run specific scenario
dotnet run basic          # All basic features
dotnet run intermediate   # Include enums and complex data
dotnet run advanced       # Full language features

# Run specific test case within scenario
dotnet run basic SimpleConfig
dotnet run intermediate EnumUsage
dotnet run advanced CompleteFeature

# Partial matching supported
dotnet run a builtin      # Matches "BuiltinSystem" in advanced
dotnet run i complex      # Matches "ComplexData" in intermediate

Short Form Arguments

dotnet run b              # Basic
dotnet run i              # Intermediate  
dotnet run a              # Advanced
dotnet run d              # Default

Test Features

Basic Level Features

  • @CONFIG section processing with feature control
  • @DLM module selection (DCompressor, DAuditor, DEncryptor, DErrorHandler)
  • ✅ Simple @DATA with table/group syntax
  • ✅ Basic data types: int, float, double, string, bool, arrays
  • ✅ Hex colors (#RGB, #RGBA, #RRGGBB, #RRGGBBAA)
  • ✅ Prefixed constructors: b:(), t:(), r:()
  • ✅ Date and timestamp handling
  • ✅ Error recovery and synchronization

Intermediate Level Features

  • ✅ All basic features
  • @ENUMS section with named constants
  • ✅ Enum value usage in data sections
  • ✅ Complex nested data structures
  • ✅ Multi-environment configurations
  • ✅ Advanced data lifecycle modules

Advanced Level Features

  • ✅ All intermediate features
  • @QUICKFUNCS section with function scoping
  • @EVENTS section with auto-firing compilation events
  • ✅ Registry-based built-in system:
    • Static Object Registry: Math.max(), DateTime.now(), Array.range()
    • Instance Method Registry: .toUpper(), .length(), .format()
  • ✅ Function scoping: global, group-specific, object-specific
  • ✅ String interpolation: $"text {expression}"
  • ✅ Method chaining: value.method1().method2()
  • ✅ Full expression capabilities: arithmetic, comparison, logical operations
  • ✅ CONFIG and ENUM access in events
  • ✅ Dix system functions: Dix.logEvent(), Dix.getSystemInfo()

Key DixScript Language Features Tested

Table/Group Syntax (27% More Compact than TOML)

@DATA(
  // Simple properties
  app_name = "GameSystem",
  
  // Table properties (single line)
  server.config: host = "localhost", port = 3000,
  
  // Group arrays with double colon
  world.levels::
    { name = "Forest", difficulty = 1 },
    { name = "Cave", difficulty = 2 }
)

Function Scoping System

@QUICKFUNCS(
  // Global scope - callable anywhere in DATA
  ~calculateBonus<int> => global (base<int>) {
    return Math.min(base * 1.5, 10000);
  },
  
  // Group scope - only callable within server.config group
  ~validateServer<bool> => server.config (host<string>, port<int>) {
    return host.length() > 0 && port > 1000;
  }
)

@DATA(
  server.config:
    host = "localhost",
    port = 8080,
    // Function using variables from same group
    is_valid<bool> = validateServer(host, port)
)

Registry-Based Built-in System

@QUICKFUNCS(
  ~testBuiltins<string> => global (text<string>, numbers<array>) {
    // Static object methods
    current_time = DateTime.now();
    max_number = Math.max(numbers);
    
    // Instance methods with chaining
    processed_text = text.trim().toUpper().substring(0, 10);
    formatted_time = current_time.format("yyyy-MM-dd HH:mm:ss");
    
    return $"Processed: {processed_text} at {formatted_time}";
  }
)

Event System with Auto-firing

@EVENTS(
  on:parse {
    // Access CONFIG values
    version = config.version;
    
    // Use built-ins and string interpolation
    timestamp = DateTime.now().format("HH:mm:ss");
    Dix.logEvent($"Parse started for v{version} at {timestamp}");
  },
  
  on:compile {
    // Complex built-in usage
    performance = Math.max(Random.range(50, 100), 75);
    Dix.logEvent($"Compilation performance: {performance}%");
  }
)

Expected Output

Successful Basic Test

=== DixScript Console Application ===
Selected Test Scenario: Basic
Selected Test Case: SimpleConfig

=== Stage 1: Config Section Processing ===
✅ Config section processed successfully

=== Stage 2: Lexical Analysis ===
✅ Tokenization complete: 156 tokens generated

=== Stage 3: Parsing ===
✅ Parse Results: DixScript AST

=== Stage 4: Semantic Analysis ===
✅ Semantic Validity: VALID
Error Count: 0

=== Processing Summary ===
Test Scenario: Basic
DixScript Version: 1.0.0
Features Enabled: basic
Token Count: 156
Overall Quality: ✅ EXCELLENT (Moderate)
Processing Status: ✅ SUCCESS

Advanced Test with Functions

=== DixScript Console Application ===
Selected Test Scenario: Advanced
Selected Test Case: CompleteFeature

=== Stage 1: Config Section Processing ===
✅ Config section processed successfully:
   CONFIG(version -> "2.0.0", features -> "advanced")

=== Stage 2: Lexical Analysis ===
✅ Tokenization complete: 847 tokens generated

=== Stage 3: Parsing ===
✅ Parse Results: Complete AST with QuickFunctions and Events

=== Stage 4: Semantic Analysis ===
✅ Semantic Validity: VALID
✅ Function scoping validation passed
✅ Built-in registry validation passed
Error Count: 0

=== Processing Summary ===
Test Scenario: Advanced
Features Enabled: advanced
Token Count: 847
Overall Quality: ✅ EXCELLENT (Very Complex)
Processing Status: ✅ SUCCESS

Test Performance Metrics

The console application tracks various performance metrics:

  • Token Generation Speed: Tokens generated per second
  • Parse Time: Time to build AST from tokens
  • Semantic Analysis: Validation time for complex features
  • Memory Usage: Estimated memory consumption
  • Throughput: Characters processed per second

Typical Performance (on modern hardware)

  • Basic Tests: 50-200 tokens, 5-15ms processing time
  • Intermediate Tests: 200-500 tokens, 15-50ms processing time
  • Advanced Tests: 500-1000+ tokens, 50-150ms processing time

Error Handling and Recovery

The test system includes comprehensive error handling:

Syntax Error Recovery

@DATA(
  valid_prop = "correct",
  bad_prop = "missing quote,     // ❌ Intentional error
  recovered_prop = "continues"   // ✅ Parser recovers
)

Missing Section Handling

  • Missing @CONFIG: Error reported, pipeline stops
  • Missing @DATA: Warning issued, continues processing
  • Invalid DLM modules: Warning with fallback options

Semantic Error Detection

  • Function scope violations
  • Undefined enum references
  • Type mismatches in expressions
  • Invalid built-in method calls

Integration with CI/CD

The test system is designed to work seamlessly with the GitHub Actions workflow:

# In run-dixscript.yml
- name: Run comprehensive tests
  run: |
    echo "Testing Basic Features"
    dotnet run basic
    
    echo "Testing Intermediate Features"  
    dotnet run intermediate
    
    echo "Testing Advanced Features"
    dotnet run advanced

Development and Debugging

Debug Mode Features

  • Detailed token output (first 20 tokens shown)
  • Step-by-step pipeline execution
  • Comprehensive error messages with line/column information
  • Performance timing for each stage

Adding New Tests

  1. Add test case to appropriate TestFiles/*.cs file
  2. Update GetAllTests() method to include new test
  3. Test with: dotnet run [scenario] [testname]

Test Case Guidelines

  • Basic: Focus on core parsing and simple data structures
  • Intermediate: Add complexity with enums and nested structures
  • Advanced: Include functions, events, and built-in usage
  • Include both positive and negative test cases
  • Add comments explaining test objectives

Troubleshooting

Common Issues

"Test case not found"

  • Check spelling of test case name
  • Use partial matching: dotnet run a builtin instead of BuiltinSystem
  • Run without test case to see available options

"Config processing failed"

  • Check for missing closing parentheses in @CONFIG
  • Verify required fields: version, features
  • Ensure proper -> syntax for key-value pairs

"Tokenization errors"

  • Check for unmatched quotes, braces, or parentheses
  • Verify section syntax: @SECTION(content)
  • Look for invalid characters or escape sequences

"Semantic validation failed"

  • Check function scoping rules
  • Verify enum values exist before usage
  • Ensure built-in method calls use correct syntax

Future Enhancements

  • Performance Benchmarking: Automated performance regression testing
  • Test Coverage: Code coverage analysis for parser components
  • Memory Profiling: Detailed memory usage analysis
  • Parallel Testing: Run multiple test scenarios simultaneously
  • Custom Test Definition: JSON-based external test case definitions
  • Integration Tests: Cross-section dependency validation