# Path: clearly/utils/safe_compiler.py
# NON_PRINTABLE_PATTERN = re.compile('[\x00-\x1f]')
# def safe_compile_text(txt: str, raises: bool = False) -> Any:
#     def _convert(node):
# def _encode_to_hex(match: Match) -> str:


import pytest
from clearly.utils.safe_compiler import CallDescriptor, safe_compile_text
    ('{"1":2}', {'1': 2}),
    ('{1:"2"}', {1: '2'}),
    ('{"1":"2"}', {'1': '2'}),
    ('{True:False}', {True: False}),
    ('{None:None}', {None: None}),
    ('{"1": 2, False: None}', {'1': 2, False: None}),

    # function dicts
    ('dict()', {}),
    ('dict(a=2)', {'a': 2}),
    ('dict(a=2,)', {'a': 2}),
    ('dict(a="ok")', {'a': 'ok'}),
    ('dict(a=False)', {'a': False}),
    ('dict(a=None)', {'a': None}),
    ('dict(a=1, b=2)', {'a': 1, 'b': 2}),
    ('dict(a=1, b="2", c=True, d=None)', {'a': 1, 'b': '2', 'c': True, 'd': None}),

    # complex structures
    ('1, (2, True, {3, 4}), ["a", "b"], {1:2}', (1, (2, True, {3, 4}), ["a", "b"], {1: 2})),
    ('[1, (2, 3), {"ok": True}]', [1, (2, 3), {"ok": True}]),
    ('{(1, 2): ["a", "b"], True: {5, 6, 7}}', {(1, 2): ["a", "b"], True: {5, 6, 7}}),

    # attributes
    ('rogerio', 'rogerio'),
    ('roger.io', 'roger.io'),

    # functions
    ('rogerio()', CallDescriptor('rogerio', None, None)),
    ('datetime(2018,1,1)', CallDescriptor('datetime', (2018, 1, 1), None)),
    ('datetime.timedelta(secs=1)', CallDescriptor('datetime.timedelta', None, {'secs': 1})),

# Path: clearly/utils/safe_compiler.py
# NON_PRINTABLE_PATTERN = re.compile('[\x00-\x1f]')
# def safe_compile_text(txt: str, raises: bool = False) -> Any:
#     def _convert(node):
# def _encode_to_hex(match: Match) -> str:


# Path: tests/unit/utils/test_safe_compiler.py
import pytest
from clearly.utils.safe_compiler import CallDescriptor, safe_compile_text

    ('{"1":2}', {'1': 2}),
    ('{1:"2"}', {1: '2'}),
    ('{"1":"2"}', {'1': '2'}),
    ('{True:False}', {True: False}),
    ('{None:None}', {None: None}),
    ('{"1": 2, False: None}', {'1': 2, False: None}),

    # function dicts
    ('dict()', {}),
    ('dict(a=2)', {'a': 2}),
    ('dict(a=2,)', {'a': 2}),
    ('dict(a="ok")', {'a': 'ok'}),
    ('dict(a=False)', {'a': False}),
    ('dict(a=None)', {'a': None}),
    ('dict(a=1, b=2)', {'a': 1, 'b': 2}),
    ('dict(a=1, b="2", c=True, d=None)', {'a': 1, 'b': '2', 'c': True, 'd': None}),

    # complex structures
    ('1, (2, True, {3, 4}), ["a", "b"], {1:2}', (1, (2, True, {3, 4}), ["a", "b"], {1: 2})),
    ('[1, (2, 3), {"ok": True}]', [1, (2, 3), {"ok": True}]),
    ('{(1, 2): ["a", "b"], True: {5, 6, 7}}', {(1, 2): ["a", "b"], True: {5, 6, 7}}),

    # attributes
    ('rogerio', 'rogerio'),
    ('roger.io', 'roger.io'),

    # functions
    ('rogerio()', CallDescriptor('rogerio', None, None)),
    ('datetime(2018,1,1)', CallDescriptor('datetime', (2018, 1, 1), None)),
    ('datetime.timedelta(secs=1)', CallDescriptor('datetime.timedelta', None, {'secs': 1})),

    ('1, f(1), g(x=2)', (1, CallDescriptor('f', (1,), None), CallDescriptor('g', None, {'x': 2}))),