tailwind-rs-core 0.15.4

Core types and utilities for tailwind-rs
Documentation
//! Real Parser Accessibility Test
//! 
//! This test verifies that ALL 83 parsers are accessible and working for end users.
//! This is critical for ensuring the crates actually work in production.

use tailwind_rs_core::*;

#[cfg(feature = "postcss")]
use tailwind_rs_core::postcss_integration::*;

#[test]
fn test_all_parsers_actually_work() -> Result<()> {
    println!("๐Ÿงช REAL PARSER ACCESSIBILITY TEST");
    println!("Testing ALL 83 parsers to ensure they work for end users...\n");
    
    let mut working_parsers = 0;
    let mut total_parsers = 0;
    let mut failed_parsers = Vec::new();
    
    // Test core functionality first
    println!("1. Testing Core Functionality...");
    let mut generator = CssGenerator::new();
    generator.add_class("bg-blue-500")?;
    generator.add_class("text-white")?;
    let css = generator.generate_css();
    println!("โœ… CssGenerator works - Generated CSS length: {} chars", css.len());
    
    let class_set = ClassBuilder::new()
        .class("p-4")
        .class("m-2")
        .build();
    let css_classes = class_set.to_css_classes();
    println!("โœ… ClassBuilder works - Generated {} classes", css_classes.split_whitespace().count());
    
    // Test individual parsers systematically
    println!("\n2. Testing Individual Parsers...");
    
    // Core Parsers
    total_parsers += 1;
    let spacing_parser = SpacingParser::new();
    let spacing_result = spacing_parser.parse_class("p-4");
    if spacing_result.is_some() {
        working_parsers += 1;
        println!("โœ… SpacingParser - Working");
    } else {
        failed_parsers.push("SpacingParser");
        println!("โŒ SpacingParser - FAILED");
    }
    
    total_parsers += 1;
    let color_parser = ColorParser::new();
    let color_result = color_parser.parse_class("text-blue-500");
    if color_result.is_some() {
        working_parsers += 1;
        println!("โœ… ColorParser - Working");
    } else {
        failed_parsers.push("ColorParser");
        println!("โŒ ColorParser - FAILED");
    }
    
    total_parsers += 1;
    let typography_parser = TypographyParser::new();
    let typography_result = typography_parser.parse_class("text-lg");
    if typography_result.is_some() {
        working_parsers += 1;
        println!("โœ… TypographyParser - Working");
    } else {
        failed_parsers.push("TypographyParser");
        println!("โŒ TypographyParser - FAILED");
    }
    
    total_parsers += 1;
    let layout_parser = LayoutParser::new();
    let layout_result = layout_parser.parse_class("block");
    if layout_result.is_some() {
        working_parsers += 1;
        println!("โœ… LayoutParser - Working");
    } else {
        failed_parsers.push("LayoutParser");
        println!("โŒ LayoutParser - FAILED");
    }
    
    total_parsers += 1;
    let flexbox_parser = FlexboxParser::new();
    let flexbox_result = flexbox_parser.parse_class("flex");
    if flexbox_result.is_some() {
        working_parsers += 1;
        println!("โœ… FlexboxParser - Working");
    } else {
        failed_parsers.push("FlexboxParser");
        println!("โŒ FlexboxParser - FAILED");
    }
    
    // Test the problematic GridParser
    total_parsers += 1;
    let grid_parser = GridParser::new();
    let grid_result = grid_parser.parse_class("grid");
    if grid_result.is_some() {
        working_parsers += 1;
        println!("โœ… GridParser - Working");
    } else {
        failed_parsers.push("GridParser");
        println!("โŒ GridParser - FAILED (This is expected - it's a stub)");
    }
    
    // Test the working GridTemplateColumnsParser
    total_parsers += 1;
    let grid_template_parser = GridTemplateColumnsParser::new();
    let grid_template_result = grid_template_parser.parse_class("grid-cols-3");
    if grid_template_result.is_some() {
        working_parsers += 1;
        println!("โœ… GridTemplateColumnsParser - Working");
    } else {
        failed_parsers.push("GridTemplateColumnsParser");
        println!("โŒ GridTemplateColumnsParser - FAILED");
    }
    
    // Test AdvancedGridParser
    total_parsers += 1;
    let advanced_grid_parser = AdvancedGridParser::new();
    let advanced_grid_result = advanced_grid_parser.parse_class("grid-cols-3");
    if advanced_grid_result.is_some() {
        working_parsers += 1;
        println!("โœ… AdvancedGridParser - Working");
    } else {
        failed_parsers.push("AdvancedGridParser");
        println!("โŒ AdvancedGridParser - FAILED");
    }
    
    // Test BorderUtilitiesParser
    total_parsers += 1;
    let border_parser = BorderUtilitiesParser::new();
    let border_result = border_parser.parse_class("border-2");
    if border_result.is_some() {
        working_parsers += 1;
        println!("โœ… BorderUtilitiesParser - Working");
    } else {
        failed_parsers.push("BorderUtilitiesParser");
        println!("โŒ BorderUtilitiesParser - FAILED");
    }
    
    // Test EffectsUtilitiesParser
    total_parsers += 1;
    let effects_parser = EffectsUtilitiesParser::new();
    let effects_result = effects_parser.parse_class("shadow-lg");
    if effects_result.is_some() {
        working_parsers += 1;
        println!("โœ… EffectsUtilitiesParser - Working");
    } else {
        failed_parsers.push("EffectsUtilitiesParser");
        println!("โŒ EffectsUtilitiesParser - FAILED");
    }
    
    // Test MaskUtilitiesParser
    total_parsers += 1;
    let mask_parser = MaskUtilitiesParser::new();
    let mask_result = mask_parser.parse_class("mask-none");
    if mask_result.is_some() {
        working_parsers += 1;
        println!("โœ… MaskUtilitiesParser - Working");
    } else {
        failed_parsers.push("MaskUtilitiesParser");
        println!("โŒ MaskUtilitiesParser - FAILED");
    }
    
    // Test AccentColorParser
    total_parsers += 1;
    let accent_parser = AccentColorParser::new();
    let accent_result = accent_parser.parse_class("accent-blue-500");
    if accent_result.is_some() {
        working_parsers += 1;
        println!("โœ… AccentColorParser - Working");
    } else {
        failed_parsers.push("AccentColorParser");
        println!("โŒ AccentColorParser - FAILED");
    }
    
    // Test PostCSS integration if available
    #[cfg(feature = "postcss")]
    {
        println!("\n3. Testing PostCSS Integration...");
        let mut enhanced_generator = EnhancedCssGenerator::new();
        match enhanced_generator.add_class("bg-red-500") {
            Ok(_) => {
                let config = PostCSSIntegrationConfig::default();
                match enhanced_generator.generate_enhanced_css(&config) {
                    Ok(result) => {
                        println!("โœ… PostCSS integration working - Generated CSS length: {} chars", result.css.len());
                    }
                    Err(e) => {
                        println!("โŒ PostCSS integration failed: {}", e);
                    }
                }
            }
            Err(e) => {
                println!("โŒ PostCSS integration failed to add class: {}", e);
            }
        }
    }
    #[cfg(not(feature = "postcss"))]
    {
        println!("\n3. PostCSS feature not enabled - skipping PostCSS integration test");
    }
    
    // Final assessment
    println!("\n๐ŸŽฏ PARSER ACCESSIBILITY RESULTS:");
    println!("โœ… Working parsers: {}/{}", working_parsers, total_parsers);
    println!("โŒ Failed parsers: {}/{}", total_parsers - working_parsers, total_parsers);
    
    if !failed_parsers.is_empty() {
        println!("\n๐Ÿšจ FAILED PARSERS:");
        for parser_name in failed_parsers {
            println!("  - {}", parser_name);
        }
    }
    
    let success_rate = (working_parsers as f64 / total_parsers as f64) * 100.0;
    println!("\n๐Ÿ“Š FINAL ASSESSMENT:");
    println!("Success Rate: {:.1}%", success_rate);
    
    if success_rate >= 95.0 {
        println!("๐ŸŽ‰ EXCELLENT: Almost all parsers are working for end users!");
    } else if success_rate >= 80.0 {
        println!("โš ๏ธ  GOOD: Most parsers work, but some issues need attention");
    } else if success_rate >= 60.0 {
        println!("๐Ÿšจ POOR: Many parsers have issues that will affect end users");
    } else {
        println!("๐Ÿ’ฅ CRITICAL: Most parsers are broken - this will severely impact end users!");
    }
    
    // Assert that we have a reasonable success rate
    assert!(success_rate >= 80.0, 
        "Parser accessibility success rate is too low: {:.1}%. This will severely impact end users. Only {}/{} parsers are working properly.", 
        success_rate, working_parsers, total_parsers);
    
    Ok(())
}