# Edge Case Test Findings for Wasot Selectors

## Summary
The edge case tests revealed several issues and behaviors in the selector parser and matching logic. This document tracks outstanding issues - resolved issues have been removed.

## Current Status (Updated 2025-08-11)
✅ All tests pass including edge cases (737+ tests)
✅ Test suite includes 45+ comprehensive edge case tests
✅ Major improvements made to identifier and attribute parsing
⚠️ Some edge cases remain unsupported but are properly handled (fail gracefully)

## Parser Issues Still Present

### 1. Missing Attribute Keys
- `[=value]` fails to parse - expects a key before `=`
- **Status**: Fails gracefully with parse error

### 2. Double Dots in Classes
- `.class..class2` fails to parse
- `..double-dot` fails to parse
- Parser gets confused by consecutive dots
- **Status**: Fails gracefully with parse error

### 3. Escape Sequences Not Supported
- `.class\.with\.dots` fails - backslash escaping not implemented
- `#id\#with\#hash` fails - same issue
- CSS allows escaping special characters in identifiers
- **Status**: Not implemented, handled in test_invalid_escape_sequences

### 4. Emoji and Special Unicode Edge Cases
- `.😀` (emoji class) fails to parse
- `#\u{200B}invisible` (zero-width space) fails to parse
- **Status**: Not supported, but other Unicode (Cyrillic `.класс`, Korean `#아이디`) works fine


## Features That Work Correctly

### 1. Quoted Identifiers
- Quoted classes and IDs parse correctly
- Spaces in quoted identifiers work

### 2. Multiple IDs
- `#id#id2` parses (though invalid in CSS, it doesn't crash)

### 3. Unicode Support (Mostly)
- Cyrillic (`.класс`), Korean (`#아이디`) work fine
- Issue is with specific edge cases like emoji

### 4. Pseudo-Class Handling
- `:nth-child(0)` parses (though invalid in CSS)
- Very large numbers parse correctly
- Nested `:not()` parses (e.g., `:not(:not(p))`)

### 5. Universal Selector
- `**` (double universal) parses without crashing
- All universal selector combinations work

### 6. Stress Tests Pass
- Deep nesting (1000 levels) handled gracefully
- Many classes (100+) work fine
- Complex selectors with all features combined work

## Recently Fixed Issues (2025-08-11)

### ✅ Numeric Identifiers
- `.123class` and `#123id` now parse correctly
- Selector grammar updated to allow digits at the start of identifiers
- Tests updated and passing

### ✅ Unicode ID Support
- `#спец` (Cyrillic) and other Unicode IDs now parse correctly
- Wasot parser regex updated to support Unicode characters in IDs (\p{L})
- Also added support for uppercase IDs (e.g., `:TEST`)

### ✅ Empty Attribute Values
- `[attr=]` now parses correctly as an attribute with empty value
- Parser updated to handle optional values in attribute selectors
- Matching logic works correctly with empty values

### ✅ Attribute Selector Parser Assertion
- Previously had internal assertion failure in `parse_identifier`
- **Resolved**: No longer crashes, all attribute tests pass

### ✅ Error Handling
- All malformed selectors fail gracefully without panics
- Proper error messages returned for invalid input

## Recommendations

### High Priority Enhancements
1. Support numeric identifiers (with proper escaping)
2. Fix Unicode ID parsing (e.g., `#спец`)
3. Handle empty attribute values gracefully

### Medium Priority Enhancements
1. Implement escape sequence support for special characters
2. Better error messages for specific failure types

### Low Priority / Future Work
1. Support for emoji in identifiers
2. Handle zero-width and special Unicode characters
3. Validate selector semantics (e.g., only one ID per selector)

## Test Coverage Improvements
The edge case tests provide excellent coverage for:
- Malformed input handling
- Unicode support
- Performance stress testing
- Complex selector combinations
- Matching logic edge cases

These tests ensure the selector system is robust and handles real-world edge cases gracefully.