+
    ¾¾jš  ã                   óh   € R t ^ RIt^ RIt^ RIHt ^ RIHt R R ltR R ltR t	R	 t
R
 tR tR tR# )ay  Regression test for RecursionError on deeply-nested jCal.

The iCal parser/serializer was made iterative to survive deep nesting
(see https://github.com/collective/icalendar/issues/1370), but the jCal
counterparts :meth:`Component.from_jcal` and :meth:`Component.to_jcal`
remained recursive: a small jCal payload nesting components a few hundred
levels deep raised an uncaught ``RecursionError`` at the default recursion
limit (1000).

These tests mirror ``test_walk_handles_deeply_nested_components`` and use a
depth comfortably above the recursion limit so the recursive implementation
would fail while the iterative one succeeds.
N)Ú	Component)ÚJCalParsingErrorc                ó0   € V ^8„  d   QhR\         R\        /# )é   ÚdepthÚreturn)ÚintÚlist)Úformats   "Úb/home/ralf/ical-fahrzeuge/venv/lib/python3.14/site-packages/icalendar/tests/test_jcal_recursion.pyÚ__annotate__r      s   € ÷ ñ œð ¤ñ ó    c                ó”   € RR/ RR.R/ RR... .pTp\        V 4       F'  pRR/ RR	... .pV^,          P                  V4       TpK)  	  V# )
z?Return a jCal VCALENDAR with ``depth`` levels of nested VEVENT.Ú	vcalendarÚversionÚtextú2.0Úprodidz-//test//test//ENÚveventÚuidznested@example.com)ÚrangeÚappend)r   ÚrootÚinnerÚ_Úchilds   &    r   Ú_nested_jcalr      sv   € ð 	Ø
�R˜ Ð	'¨(°B¸Ð@SÐ)TÐUØ
ð€Dð
 €EÜ�5Ž\ˆØ˜U B¨Ð0DÐEÐFÈÐKˆØˆa��‰˜ÔØŠñ ð €Kr   c                ó0   € V ^8„  d   QhR\         R\        /# )r   Ú	componentr   )r   r   )r
   s   "r   r   r   &   s   € ÷ ñ œið ¬Cñ r   c                ój   € ^ pV P                   '       d   V^,          pV P                   ^ ,          p K0  V# )z@Count how many levels of single-child nesting ``component`` has.)Úsubcomponents)r   r   s   & r   Ú_nesting_depthr!   &   s1   € à€EØ
×
!×
!Ð
!Ø��
ˆØ×+Ñ+¨AÕ.Š	Ø€Lr   c                 óÆ   € \         P                  ! 4       ^2,           p \        P                  ! \	        V 4      4      pVP
                  R8X  g   Q h\        V4      V 8X  g   Q hR# )zDDeeply nested jCal must parse without exceeding the recursion limit.Ú	VCALENDARN)ÚsysÚgetrecursionlimitr   Ú	from_jcalr   Únamer!   )r   Úcalendars     r   Ú/test_from_jcal_handles_deeply_nested_componentsr)   /   sO   € ä×!Ò!Ó# bÕ(€EÜ×"Ò"¤<°Ó#6Ó7€HØ�=‰=˜KÔ'Ð'Ð'Ü˜(Ó# uÔ,Ð,Ò,r   c                 ó  € \         P                  ! 4       ^2,           p \        P                  ! \	        V 4      4      pVP                  4       pT^ rCV^,          '       d   V^,          pV^,          ^ ,          pK*  W@8X  g   Q hR# )z7Serializing a deeply nested component must not recurse.N)r$   r%   r   r&   r   Úto_jcal)r   r(   ÚjcalÚnodeÚlevelss        r   Ú-test_to_jcal_handles_deeply_nested_componentsr/   7   sh   € ä×!Ò!Ó# bÕ(€EÜ×"Ò"¤<°Ó#6Ó7€HØ×ÑÓ€Dà˜ˆ&Ø
ˆq�'Œ'Ø�!�ˆØ�A�w�q�zŠØŒ?ÐŠ?r   c                 ó   € \         P                  ! 4       ^2,           p \        V 4      p\        P                  ! V4      P                  4       p\        P                  ! V4      P                  4       pY#rT^ p \        V4      ^8X  g   Q h\        V4      ^8X  g   Q hV^ ,          V^ ,          8X  g   Q hV^,          V^,          8X  g   Q hV^,          '       g   V^,          '       d   Q hM^\        V^,          4      \        V^,          4      u;8X  d	   ^8X  g   Q h Q hV^,          ^ ,          V^,          ^ ,          rTV^,          pKÒ  W`8X  g   Q hR# )z;from_jcal -> to_jcal -> from_jcal is stable at large depth.N)r$   r%   r   r   r&   r+   Úlen)r   r,   ÚonceÚtwiceÚaÚbr.   s          r   Ú#test_deeply_nested_jcal_round_tripsr6   D   s  € ä×!Ò!Ó# bÕ(€EÜ˜Ó€DÜ×Ò˜tÓ$×,Ñ,Ó.€DÜ×Ò Ó%×-Ñ-Ó/€Eð €qØ€FØ
ô �1‹v˜Œ{Ðˆ{Ü�1‹v˜Œ{Ðˆ{Ø��t�q˜•tŒ|Ðˆ|Ø��t�q˜•tŒ|Ðˆ|Ø��tŒtØ˜—t”tˆO�8ØÜ�1�Q•4‹yœC  !¥›IÖ*¨Ô*Ð*Ñ*Ð*Ð*Ø��t�A�w˜˜!�˜Q�ˆ1Ø�!�ŠØŒ?ÐŠ?r   c                 ó¸  € RR/ RR.R/ RR..RR/ RR	..R
R/ RR.R/ RR.R/ RR... .R
R/ RR.R/ RR... ...RR/ RR... ...p \         P                  ! V 4      P                  4       pV^,          ^ ,          ^,          ^ ,          ^,          R	8X  g   Q hV^,          ^,          ^,          ^ ,          ^,          R8X  g   Q h\        V^,          ^ ,          ^,          4      ^8X  g   Q hV^,          ^ ,          ^,          ^ ,          ^,          ^ ,          ^,          R8X  g   Q hV^,          ^ ,          ^,          ^,          ^,          ^ ,          ^,          R8X  g   Q hR# )aH  to_jcal preserves sibling order in branching (non-linear) trees.

The round-trip test above only exercises a single child per node. The
iterative stack walk appends each child to its parent before pushing it,
so sibling order must be independent of the LIFO pop order -- this locks
that in with multiple siblings at two levels.
r   r   r   r   r   z-//test//ENr   r   z
first@testÚvalarmÚactionÚDISPLAYÚdescriptionÚAÚtriggerÚdurationz-PT15MÚAUDIOz-PT5Mzsecond@testN)r   r&   r+   r1   )r,   Úresults     r   Útest_branching_jcal_round_tripsrA   _   s¥  € ð 	Ø
�R˜ Ð	'¨(°B¸ÀÐ)NÐOð Ø˜˜V \Ð2Ð3ð !à% r¨6°9Ð=Ø*¨B°¸Ð<Ø&¨¨J¸ÐAðð
 ðð !à% r¨6°7Ð;Ø&¨¨J¸Ð@ðð ðððð. ˜  F¨MÐ:Ð;¸RÐ@ð1	
ð€Dô< × Ò  Ó&×.Ñ.Ó0€Fà�!�9�Q�<˜�?˜1Õ˜aÕ  LÔ0Ð0Ð0Ø�!�9�Q�<˜�?˜1Õ˜aÕ  MÔ1Ð1Ð1äˆv�a�y˜�|˜A�Ó 1Ô$Ð$Ð$Ø�!�9�Q�<˜�?˜1Õ˜aÕ  Õ# AÕ&¨)Ô3Ð3Ð3Ø�!�9�Q�<˜�?˜1Õ˜aÕ  Õ# AÕ&¨'Ô1Ð1Ò1r   c                 óÐ   € R. R. R. ^*......p \         P                  ! \        RR7      ;_uu_ 4        \        P                  ! V 4       RRR4       R#   + '       g   i     R# ; i)z?Errors deep in the tree still report the accumulated jCal path.r   r   r8   zR\[2\]\[0\]\[2\]\[0\]\[2\]\[0\] in Alarm: A component must be a list with 3 items\.)ÚmatchN)ÚpytestÚraisesr   r   r&   )Úbads    r   Ú,test_error_path_is_preserved_for_nested_jcalrG   �   sj   € ð 	Ø
Ø
�B˜( B¨¨Ð-Ð.Ð	/Ð0ð€Cô
 
�ŠÜð5÷
ö 
ô
 	×Ò˜CÔ ÷
÷ 
÷ 
ò 
ús   ³AÁA%	)Ú__doc__r$   rD   Ú	icalendarr   Úicalendar.errorr   r   r!   r)   r/   r6   rA   rG   © r   r   Ú<module>rL      s<   ðñó ã å Ý ,õõò-ò
òò6-2ô`!r   