§
     Όc°  γ                   σJ    d dl Zd dlmc mZ d dlmZ d Zd Zd Z	d Z
d ZdS )ι    N)Ϊrotatec                  σ   d} d}t          | |¦  «        }d}||k    }|sΪt          j        d|fd||f¦  «        dt          j        ¦   «         v st          j        t           ¦  «        rt          j        t           ¦  «        ndt          j        | ¦  «        t          j        |¦  «        t          j        |¦  «        t          j        |¦  «        dz  }dd	|iz  }t          t          j        |¦  «        ¦  «        d x} x}x}x}}d} d}| }t          | |¦  «        }d
}||k    }|sΪt          j        d|fd||f¦  «        dt          j        ¦   «         v st          j        t           ¦  «        rt          j        t           ¦  «        ndt          j        | ¦  «        t          j        |¦  «        t          j        |¦  «        t          j        |¦  «        dz  }	dd|	iz  }
t          t          j        |
¦  «        ¦  «        d x} x}x}x}x}}d S )NΪhelloι   Ϊllohe©ϊ==)z9%(py6)s
{%(py6)s = %(py0)s(%(py2)s, %(py4)s)
} == %(py9)sr   )Ϊpy0Ϊpy2Ϊpy4Ϊpy6Ϊpy9ϊassert %(py11)sΪpy11Ϊlohel)z;%(py7)s
{%(py7)s = %(py0)s(%(py2)s, -%(py4)s)
} == %(py10)s)r
   r   r   Ϊpy7Ϊpy10zassert %(py12)sΪpy12©	r   Ϊ
@pytest_arΪ_call_reprcompareΪ@py_builtinsΪlocalsΪ_should_repr_global_nameΪ	_safereprΪAssertionErrorΪ_format_explanation)Ϊ@py_assert1Ϊ@py_assert3Ϊ@py_assert5Ϊ@py_assert8Ϊ@py_assert7Ϊ@py_format10Ϊ@py_format12Ϊ@py_assert6Ϊ@py_assert9Ϊ@py_format11Ϊ@py_format13s              ϊ2/home/feoh/src/personal/bitesofpy/8/test_rotate.pyΪtest_small_rotater*      s   Ψ@Π@M@@@@@Π(@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@@@@M@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Ψ@Π@@@@M@@@@@Π)@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@@@@M@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@σ    c                  σ°   d} d}d}t          | |¦  «        }||k    }|s0t          j        d|fd||f¦  «        dt          j        ¦   «         v st          j        t           ¦  «        rt          j        t           ¦  «        nddt          j        ¦   «         v st          j        | ¦  «        rt          j        | ¦  «        ndt          j        |¦  «        t          j        |¦  «        dt          j        ¦   «         v st          j        |¦  «        rt          j        |¦  «        ndd	z  }d
d|iz  }t          t          j        |¦  «        ¦  «        d x}x}}d S )Nzbob and julian love pybites!zlove pybites!bob and julian ι   r   )z9%(py5)s
{%(py5)s = %(py0)s(%(py1)s, %(py3)s)
} == %(py7)sr   ΪstringΪexpected)r
   Ϊpy1Ϊpy3Ϊpy5r   ϊassert %(py9)sr   r   )r.   r/   Ϊ@py_assert2Ϊ@py_assert4r%   Ϊ@py_format8r#   s          r)   Ϊ"test_bigger_rotation_of_positive_nr7   	   s   Ψ+FΨ-HΨ@MΠ@@@@@Π)@@@@@@@@@@@Π)@@@@@@@@@@@@M@@@@@M@@@@@@@@@@@@@Π@@@@@Π@@@@@@@@@@@@@@@@@@@@@@@Π)@@@@@Π)@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@r+   c                  σΊ   d} d}d}| }t          | |¦  «        }||k    }|s0t          j        d|fd||f¦  «        dt          j        ¦   «         v st          j        t           ¦  «        rt          j        t           ¦  «        nddt          j        ¦   «         v st          j        | ¦  «        rt          j        | ¦  «        ndt          j        |¦  «        t          j        |¦  «        dt          j        ¦   «         v st          j        |¦  «        rt          j        |¦  «        ndd	z  }d
d|iz  }t          t          j        |¦  «        ¦  «        d x}x}x}}d S )Nzpybites loves julian and bob!zjulian and bob!pybites loves r-   r   )z:%(py6)s
{%(py6)s = %(py0)s(%(py1)s, -%(py3)s)
} == %(py8)sr   r.   r/   )r
   r0   r1   r   Ϊpy8ϊassert %(py10)sr   r   )r.   r/   r4   r5   r    r"   Ϊ@py_format9r'   s           r)   Ϊ"test_bigger_rotation_of_negative_nr<      s   Ψ,FΨ.HΨ@@@@MΠ@@@@@Π*@@@@@@@@@@@Π*@@@@@@@@@@@@M@@@@@M@@@@@@@@@@@@@Π@@@@@Π@@@@@@@@@@@@@@@@@@@@@@@Π*@@@@@Π*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@r+   c            
      σΦ   dx} }t          | ¦  «        }t          | |¦  «        }||k    }|sΆt          j        d|fd||f¦  «        dt	          j        ¦   «         v st          j        t          ¦  «        rt          j        t          ¦  «        nddt	          j        ¦   «         v st          j        | ¦  «        rt          j        | ¦  «        nddt	          j        ¦   «         v st          j        t           ¦  «        rt          j        t           ¦  «        nddt	          j        ¦   «         v st          j        | ¦  «        rt          j        | ¦  «        ndt          j        |¦  «        t          j        |¦  «        dt	          j        ¦   «         v st          j        |¦  «        rt          j        |¦  «        nddz  }d	d
|iz  }t          t          j	        |¦  «        ¦  «        d x}x}}d S )Nϊjulian and bob!r   )zW%(py7)s
{%(py7)s = %(py0)s(%(py1)s, %(py5)s
{%(py5)s = %(py2)s(%(py3)s)
})
} == %(py9)sr   r.   Ϊlenr/   )r
   r0   r   r1   r2   r   r   r   r   )
r?   r   r   r   r   r   r   r   r   r   )r.   r/   r5   r%   r!   r#   r$   s          r)   Ϊ"test_rotation_of_n_same_as_len_strr@      sc   Ψ)Π)FXέΠ$@@@MΠ@@@@@Π2@@@@@@@@@@@Π2@@@@@@@@@@@@M@@@@@M@@@@@@@@@@@@@Π@@@@@Π@@@@@@@@@@@@@Υ@@@@@Υ@@@@@@@@@@@@@Π$@@@@@Π$@@@@@@@@@@@@@@@@@@@@@@@Π2@@@@@Π2@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@r+   c                  σ,   d} d}d}d}t          | |¦  «        }||f}||v }|st          j        d|fd||f¦  «        dt          j        ¦   «         v st          j        t           ¦  «        rt          j        t           ¦  «        nddt          j        ¦   «         v st          j        | ¦  «        rt          j        | ¦  «        ndt          j        |¦  «        t          j        |¦  «        t          j        |¦  «        dz  }d	d
|iz  }t          t          j        |¦  «        ¦  «        dx}x}x}}dt          | ¦  «        z  }	t          | |	¦  «        }
||f}|
|v }|s0t          j        d|fd|
|f¦  «        dt          j        ¦   «         v st          j        t           ¦  «        rt          j        t           ¦  «        nddt          j        ¦   «         v st          j        | ¦  «        rt          j        | ¦  «        nddt          j        ¦   «         v st          j        |	¦  «        rt          j        |	¦  «        ndt          j        |
¦  «        t          j        |¦  «        dz  }dd|iz  }t          t          j        |¦  «        ¦  «        dx}
x}}dS )aY  
    Why are there two expected results for this test?

    This Bite can be interpreted in two ways:

    1. A slice of size n moved from one end of the string to the other
    2. A continual rotation, character by character, n number of times

    Both interpretations result in identical output, except in the case
    where the rotation size exceeds the length of the string.

    Case 1) With a slice method, slicing an entire string and placing
    it at either the beginning or end of itself simply results in the
    the original string = expected_solution1

    Case 2) With a continual rotation, rotating the string len(string)
    number of times produces a string idential to the original string.
    This means any additional rotations can be considered equivalent to
    rotating the string by rotations % len(string) = expected_solution2
    r>   z bob!julian andιd   )Ϊin)z9%(py5)s
{%(py5)s = %(py0)s(%(py1)s, %(py3)s)
} in %(py8)sr   r.   )r
   r0   r1   r2   r9   r:   r   N)z9%(py4)s
{%(py4)s = %(py0)s(%(py1)s, %(py2)s)
} in %(py7)sΪmod)r
   r0   r   r   r   r3   r   )
r   r   r   r   r   r   r   r   r   r?   )r.   Ϊexpected_solution1Ϊexpected_solution2r4   r5   r"   r%   r;   r'   rD   r   r    r6   r#   s                 r)   Ϊ%test_rotation_of_n_bigger_than_stringrG      s   π* FΨ*ΠΨ*ΠΨ@MΠ@@@@Π5π 6π 7@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@@@@M@@@@@@@@@@@@@Π@@@@@Π@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@π FΡ
CέΠΠ@@@Π5π 6π 7@@@@@@@@@@@@@@@@@@@@@@@@@@@M@@@@@M@@@@@@@@@@@@@Π@@@@@Π@@@@@@@@@@@@@Π@@@@@Π@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@r+   )Ϊbuiltinsr   Ϊ_pytest.assertion.rewriteΪ	assertionΪrewriter   r   r*   r7   r<   r@   rG   © r+   r)   ϊ<module>rM      s   πΨ              Π Π Π Π Π Π π*π *π *π
*π *π *π+π +π +π3π 3π 3π
7π 7π 7π 7π 7r+   