Files
2125_GCE/tests/__pycache__/test_text_extraction.cpython-314.pyc
T

122 lines
15 KiB
Plaintext
Raw Normal View History

2026-07-09 12:54:44 -04:00
+
ÿÜ0jº1ãóZRt^RIt^RIt^RIHt]P
P
^]!]P!444^RI H
t
H t H t H
t
HtHtHtHtHt^RIHtRtRtRtRtR tR
tR tR tR
tRtRtRt Rt!Rt"Rt#]$R8Xd]PJ!]#!44R#R#)a+Tests for GX/LAIN text extraction in gx_lain/runtime.py
Tests verify:
- normalize_segments extracts text from decompressed payload via byte ranges
- _infer_lane assigns correct lanes (0-7) based on segment metadata
- _infer_semantic_role returns correct role strings
- map_lanes organizes segments into 8 lanes
- build_envelope constructs proper ExecutionEnvelope
- fuse_lanes merges lane results correctly
- compute_resonance computes per-lane resonance
- render_output_text formats text by cognitive_mode
- make_error constructs structured error dicts
N)ÚPath) Únormalize_segmentsÚ _infer_laneÚ_infer_semantic_roleÚ map_lanesÚbuild_envelopeÚ
fuse_lanesÚcompute_resonanceÚrender_output_textÚ
make_error)Ú GXCompressorcóàRp\P!V4pRRRRRRRR ^R
^R ^R ^/RR
R ^R
^R ^R ^)/./pVR,p\W#V4p\V4^8wd\ R\V4 24R#V^,pV^,pRVR,9d!\ R\ VR,4 24R#RVR,9d!\ R\ VR,4 24R#\ R4R#)zCTest that normalize_segments extracts correct text via byte ranges.z,def hello():
print('world')
result = 42Ú source_fileútest.pyÚversionú1.0.0ÚsegmentsÚidÚseg_0ÚstartÚendÚ
start_byteÚend_byteÚseg_1zFAIL: Expected 2 segments, got FÚhelloÚtextz)FAIL: seg_0 should contain 'hello', got: Úresultz*FAIL: seg_1 should contain 'result', got: z5PASS: Text extraction via byte ranges works correctlyT)r ÚcompressrÚlenÚprintÚrepr)ÚsourceÚ
compressedÚmanifestÚ raw_segmentsrÚseg0Úseg1s Ú1/home/t420/2125_GCE/tests/test_text_extraction.pyÚ'test_normalize_segments_text_extractionr($sà
>€FÜ×& .€Jð Ø
7˜G Q¨¨q°,ÀÀ:ÈrÐ
7˜G Q¨¨q°,ÀÀJÐPRÐ 
ð€Hð˜'€LÜ
 ¸
Ó
C€Fä
ˆ6ƒ{Ü
аF³ ¨}Ðà !9€DØ !9€Dàd˜6•lÔ
Ð9¼$¸tÀF½|Ó:LÐ9MÐàt˜F•|Ô
Ð:¼4ÀÀVÅ Ó;MÐ:NÐä Ð
 ócó´RRRRR./p\P!R4p\V.V4pV'd\R\ V4 24R#\R 4R
#) z;Test normalize_segments fallback when no text is extracted.rrrrrÚtestz4FAIL: Expected empty result for empty segments, got Fz'PASS: Empty segments returns empty listT)r rrrr)r#r"rs r'Ú test_normalize_segments_fallbackr,HsXà˜y¨)°W¸jÈ"ÐM€HÜ×& .€Jä
 ¨"¨jÓ
9€Fç
Ü
ÐDÄSÈÃ[ÀMÐä Ð
 r)có^RRRRRRRR^R ^R
^R ^
/./p\WR,R 4p\V4^8wd\R
\V4 24R#V^,R,'d=RV^,R,9d(\R\V^,R,4 24R#\R4R#)z;Test normalize_segments handles corrupt payload gracefully.rrrrrrrrrrrscorruptz8FAIL: Expected 1 segment even with corrupt payload, got FrÚsegmentz#FAIL: Expected fallback text, got: z;PASS: Corrupt payload handled gracefully with fallback textT)rrrr )r#rs r'Ú'test_normalize_segments_corrupt_payloadr/Ws¸ð Ø
7˜G Q¨¨q°,ÀÀ:ÈrÐ 
ð€Hô  °:Õ*>À
Ó
K€Fä
ˆ6ƒ{Ü
ÐÈVËÈ
Ðà
ˆa…y×Ô˜Y¨f°Q­i¸Õ.?Ô
Ð3´D¸À½À6Õ9JÓ4KÐ3LÐä Ð
 r)có²\RR/4^8XgQR4h\RR/4^8XgQR4h\RR/4^8XgQR4h\R4R #)
z,Test lane inference for structural segments.rÚdef_mainzdef should be lane 0Ú class_Foozclass should be lane 0Ú
struct_headerzstruct should be lane 0z4PASS: Structural segments correctly mapped to lane 0T©rr©r)r'Útest_infer_lane_structuralr6oshä ˜˜ *¨aÔ GÐ1GÓ ˜˜kÐ +¨qÔ JÐ2JÓ ˜˜oÐ /°1Ô OÐ6OÓ  Ð
 r)cód\RR/4pV^8wd\RV 24R#\R4R#)z9Test lane inference returns default for unknown segments.rÚsome_random_segmentz%FAIL: Expected lane 1 (default), got Fz-PASS: Unclassified segments default to lane 1Tr4)Úlanes r'Útest_infer_lane_defaultr:ys8ä ˜Ð 5€Dà ˆq„yÜ
Ð5°d°VÐä Ð
 r)c óÐRR/^3RR/^3RR/^3RR/^3RR/^3RR/^3.pVF4wr\V4pW28wgK\RVR, R V R
V 24R # \R 4R
#)z+Test all lane types are correctly inferred.rÚ
comment_blockÚannotation_sectionÚhint_optimizationÚ meta_authorÚepoch_v1Ú version_2_0úFAIL: u
→ lane ú , expected Fz'PASS: All lane types correctly inferredTr4©Úcasesr.ÚexpectedÚactuals r'Útest_infer_lane_all_typesrHð Ð  !Ð
Ð$Ð % 
Ð#Ð $ 

Ð  Ð

Ð ˜Ø

Ð  Ð

€EóˆÜ˜WÓØ Ö Ü F˜7 4=˜/¨°F°8¸;ÀxÀjÐ ñ  
Ð
 r)c óÚRR/R3RR/R3RR/R3RR/R3RR /R
3RR /R
3RR /R
3.pVF4wr\V4pW28wgK\RVR, RV RV 24R# \R4R#)z7Test semantic role inference for various segment types.rÚ
def_calculateÚ
definitionÚ
class_UserÚconstraint_validationÚ
constraintÚ
example_usageÚexampleÚmeta_descriptionÚmetaÚ comment_noteÚ
unknown_blockÚunknownrBu → rCFz+PASS: All semantic roles correctly inferredT)rrrDs r'Útest_infer_semantic_rolerVšð Ð  ,Ð
 Ð ˜
Ð'Ð (¨,Ð
Ð  
Ð"Ð # 
Ð  Ð
Ð  
€EóˆÜ% gÓØ Ö Ü F˜7 4=˜/¨¨v¨h°kÀ(ÀÐ ñ  
Ð
 r)c óˆRRR^RR/RRR^RR/RRR^RR /RR
R^RR /.p\V4p\V4^8wd\R \V4 24R
#\V^,4^8wg\V^,4^8wd\R4R
#V^,^,R,R8wd\R4R
#\R4R#)z#Test mapping segments into 8 lanes.rÚs1Ú
symbolic_lanerÚstructÚs2ÚflowÚs3ÚpredictÚs4ÚepochzFAIL: Expected 8 lanes, got Fz$FAIL: Segments not properly assignedzFAIL: Lane 0 has wrong segmentz*PASS: Segments correctly mapped to 8 lanesT©rrr©rÚlaness r'Útest_map_lanesrd°ð
ˆt_ °Ð
ˆt_ °Ð
ˆt_ °Ð
ˆt_ a¨°Ð€Hô
 €Eä
ˆ5ƒzQ„Ü
Ð,¬S°«Z¨LÐä
ˆ58ƒ}˜ÔœS  q¥›]¨aÔ
Ðà ˆQ…x…{˜DÔ Ü
Ðä Ð
 r)cóâRRRR
RR/RRR^
RR/.p\V4p\V^,4^8wd\R4R #\V^,4^8wd\R
4R #\R 4R #)z.Test that lane values outside 0-7 are clamped.rrXrYrÚnegr[Úoverz$FAIL: Negative lane not clamped to 0Fz$FAIL: Over-max lane not clamped to 7z0PASS: Lane clamping works for values outside 0-7Téÿÿÿÿrarbs r'Útest_map_lanes_clampriËs{ð
ˆt_ b¨&°%Ð