fix(pdftract-tuky): fix color clamping test and verify Phase 3.1 coordinator
Fixes: - Corrected test_color_device_rgb_clamped expected value from "#ff8080" to "#ff0080" (G value -0.5 should clamp to 0.0, not 0.5) - Fixed lifetime annotation in readability.rs (Cow<str> -> Cow<'_, str>) - Fixed unused_must_use warning in page_class.rs test Verification (notes/pdftract-tuky.md): - All 8 children of Phase 3.1 coordinator are closed - q/Q 64-level depth limit verified (test_64_nested_q_calls_succeed) - Td chain accumulation verified (test_td_chain) - Tm/Td ordering correct per ISO 72-bit spec - /Rotate normalization implemented in child pdftract-1jlpy - All 6 color operators tracked (72 graphics_state tests pass) Closes: pdftract-tuky
This commit is contained in:
parent
daa4f23114
commit
6a05f7e247
4 changed files with 82 additions and 3 deletions
|
|
@ -980,7 +980,8 @@ mod tests {
|
|||
#[test]
|
||||
fn test_color_device_rgb_clamped() {
|
||||
let color = Color::DeviceRGB([1.5, -0.5, 0.5]);
|
||||
assert_eq!(color.to_css_hex(), Some("#ff8080".into()));
|
||||
// R: 1.5 -> 1.0 -> ff, G: -0.5 -> 0.0 -> 00, B: 0.5 -> 0.5 -> 80
|
||||
assert_eq!(color.to_css_hex(), Some("#ff0080".into()));
|
||||
}
|
||||
|
||||
// Tests for matrix operations
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ mod tests {
|
|||
}
|
||||
|
||||
impl ScoredSpan for TestSpan {
|
||||
fn text(&self) -> Cow<str> {
|
||||
fn text(&self) -> Cow<'_, str> {
|
||||
Cow::Borrowed(&self.text)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ mod page_classification_tests {
|
|||
fn test_page_classification_debug_assert_fires_on_invalid_confidence() {
|
||||
// Unit test: debug_assert fires on confidence = 1.5 in dev build
|
||||
// This test only runs in debug builds where debug_assert! is active
|
||||
PageClassification::new(PageClass::Vector, 1.5, None);
|
||||
let _ = PageClassification::new(PageClass::Vector, 1.5, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
78
notes/pdftract-tuky.md
Normal file
78
notes/pdftract-tuky.md
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
# Verification Note: pdftract-tuky (Phase 3.1: Graphics State Machine coordinator)
|
||||
|
||||
## Summary
|
||||
|
||||
All 8 children of the Phase 3.1 Graphics State Machine coordinator are closed. This coordinator delivers the complete graphics state infrastructure consumed by all other Phase 3 operations.
|
||||
|
||||
## Acceptance Criteria Status
|
||||
|
||||
### 1. All 8 children closed ✅
|
||||
|
||||
All children verified closed:
|
||||
- pdftract-1jlpy: Page /Rotate normalization (commit 606e162)
|
||||
- pdftract-1os1: q/Q stack with depth limit 64 (closed)
|
||||
- pdftract-1vxh: BT/ET text object lifecycle (closed)
|
||||
- pdftract-44f6: GraphicsState struct + Color enum (closed)
|
||||
- pdftract-4dmp: Text state operators (Tc Tw Tz TL Ts Tr) (closed)
|
||||
- pdftract-4ubed: Color operators (rg RG k K cs scn) (closed)
|
||||
- pdftract-4x0y: Font binding (Tf) + text positioning operators (Td TD Tm T*) (closed)
|
||||
- pdftract-p7yll: CTM operator (cm) (closed)
|
||||
|
||||
### 2. q/Q 64 levels deep succeeds; 65th level emits GSTATE_STACK_OVERFLOW ✅
|
||||
|
||||
Verified by tests in `src/graphics_state/stack.rs`:
|
||||
- `test_64_nested_q_calls_succeed`: Pushes 64 times, all succeed
|
||||
- `test_gstate_stack_depth_limit`: 65th push fails and emits diagnostic
|
||||
- `test_max_depth_is_64`: Verifies stack limit
|
||||
|
||||
### 3. Td chain accumulates correctly ✅
|
||||
|
||||
Verified by `test_td_chain` in `src/graphics_state/state.rs`:
|
||||
```rust
|
||||
// BT 100 200 Td 50 0 Td ET should yield translation (150, 200)
|
||||
state.begin_text();
|
||||
state.move_text(100.0, 200.0);
|
||||
state.move_text(50.0, 0.0);
|
||||
// Result: (150, 200) ✅
|
||||
```
|
||||
|
||||
### 4. Tm followed by Td: Td is relative to previous text_line_matrix ✅
|
||||
|
||||
Implementation in `src/graphics_state/state.rs`:
|
||||
- `set_text_matrix`: Sets both text_matrix and text_line_matrix
|
||||
- `move_text`: Updates text_line_matrix first, then copies to text_matrix
|
||||
|
||||
This matches ISO 32000-1 Table 108 specification.
|
||||
|
||||
### 5. /Rotate 90 normalization ✅
|
||||
|
||||
Child bead pdftract-1jlpy (commit 606e162) implements page rotation normalization. The implementation:
|
||||
- Handles /Rotate 0/90/180/270 degrees
|
||||
- Applies inverse rotation matrix to all glyph bboxes after content stream execution
|
||||
- Emits INVALID_ROTATE diagnostic for illegal rotation values
|
||||
|
||||
### 6. Color operators tracked ✅
|
||||
|
||||
Verified by tests in `crates/pdftract-core/src/graphics_state.rs`:
|
||||
- `test_set_fill_gray`, `test_set_fill_rgb`, `test_set_fill_cmyk`
|
||||
- `test_set_stroke_gray`, `test_set_stroke_rgb`, `test_set_stroke_cmyk`
|
||||
- `test_color_space_component_count`
|
||||
- `test_set_fill_color_space`, `test_set_stroke_color_space`
|
||||
- `test_set_fill_color_named_spot`
|
||||
|
||||
## Test Results
|
||||
|
||||
All 72 graphics_state tests pass:
|
||||
```
|
||||
Summary [ 0.049s] 72 tests run: 72 passed, 2612 skipped
|
||||
```
|
||||
|
||||
## Changes Made
|
||||
|
||||
Fixed one incorrect test expectation in `crates/pdftract-core/src/graphics_state.rs`:
|
||||
- `test_color_device_rgb_clamped`: Corrected expected value from "#ff8080" to "#ff0080"
|
||||
(The G value -0.5 should clamp to 0.0, not 0.5)
|
||||
|
||||
## Coordinator Status
|
||||
|
||||
The Phase 3.1 Graphics State Machine is complete and ready for consumption by Phase 3.2-3.5.
|
||||
Loading…
Add table
Reference in a new issue