a
    8^i                     @   s   d dl mZmZmZmZmZ d dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZ d dlZd dlZi ZdadZdadadad adadae Zdd Z G dd de!Z"dd	 Z#d
d Z$dd Z%dd Z&ej'(de& dS )    )divisionabsolute_importwith_statementprint_functionunicode_literals)PY2
basestringbchrbordchropenpystrrangeroundstrtobytesunicodeNc                 C   s$   t du rdS t| tr t|  dS )z=
    Takes the name of a statement that is about to run.
    N)node
isinstancer   labelsadd)name r   \C:\Program Files (x86)\Steam\steamapps\common\Selene ~Apoptosis~\renpy\test\testexecution.py	take_name;   s    
r   c                   @   s   e Zd ZdZdd ZdS )TestJumpzA
    An exception that is raised in order to jump to `node`.
    c                 C   s
   || _ d S )N)r   )selfr   r   r   r   __init__L   s    zTestJump.__init__N)__name__
__module____qualname____doc__r   r   r   r   r   r   G   s   r   c                 C   s*   | t v rt |  S td| |j|jdS )zk
    Tries to look up the name with `target`. If found, returns it, otherwise
    raises an exception.
    zTestcase {} not found at {}:{}.N)	testcases	Exceptionformatfilename
linenumber)r   Z	from_noder   r   r   lookupP   s    r'   c              
   C   s   z8|du r|  }| }|du r"W qj||| | }W qjW q  tyf } z|j}d}W Y d}~q d}~0 0 q |du rvd}|||fS )z1
    Performs one execution cycle of a node.
    N)startexecuter   r   )nowr   stater(   er   r   r   execute_node\   s    r-   c                  C   s  t jjj} tdu rdS t jjjr*| js*dS | j	r>t j
	d nt j
	d tj D ]}t|ddrT dS qTtrt}dat jj| t jj }t|ttt\aaat  tdu rt jj  dS t j
 }ttkst|kr|ata|a|t | jkrt d!t"d t"d dS )zN
    Called periodically by the test code to generate events, if desired.
    Ng      $@testFzTestcase stuck at {}:{}.r      )#renpyr.   testast_testr   display	interfacesuppress_underlayforcemaximum_framerateexportspygame_sdl2eventcopy_event_queuegetattractionbehaviorruncoreget_timer-   r+   
start_timer   clear	testmouseresetget_filename_line	old_stateold_loclast_state_changetimeoutr#   r$   node_loc)r2   r,   Z
old_actionr*   locr   r   r   r)   y   s8    

r)   c                  C   sP   t jjdd} | jddddd |  }|jtvrBtd|jt|j a	d	S )
zj
    The dialogue command. This updates dialogue.txt, a file giving all the dialogue
    in the game.
    zRuns a testcase.)descriptiontestcasezThe name of a testcase to run.?default)helpnargsrP   zTestcase {} was not found.T)
r0   	argumentsArgumentParseradd_argument
parse_argsrN   r"   r#   r$   r   )apargsr   r   r   test_command   s    

rY   r.   ))
__future__r   r   r   r   r   renpy.compatr   r   r	   r
   r   r   r   r   r   r   r   r   r9   r0   r"   r   rK   r+   rG   rH   rI   rB   r=   setr   r   r#   r   r'   r-   r)   rY   rS   register_commandr   r   r   r   <module>   s(   8	: