Esempio n. 1
0
def test_nested():
    assert (nlsd.from_string(
        "the list henceforth `the list` where an item is the object where `a` is 1 and another item of `the list` is the object where `b` is 2"
    ) == [{
        "a": 1
    }, {
        "b": 2
    }])
    assert (nlsd.from_string(
        "the object henceforth `the object` where `a` is the list where an item is 1 and `b` of `the object` is the list where an item is 2"
    ) == {
        "a": [1],
        "b": [2]
    })
Esempio n. 2
0
def test_nested():
    assert (nlsd.from_string(nlsd.to_string([{
        "a": 1
    }, {
        "b": 2
    }])) == [{
        "a": 1
    }, {
        "b": 2
    }])
    assert (nlsd.from_string(nlsd.to_string({
        "a": [1],
        "b": [2]
    })) == {
        "a": [1],
        "b": [2]
    })
Esempio n. 3
0
def test_object():
    assert (nlsd.from_string(nlsd.to_string({
        "a": 1,
        "b": 2
    })) == {
        "a": 1,
        "b": 2
    })
Esempio n. 4
0
def test_bool():
    assert (nlsd.from_string(nlsd.to_string(True)) == True)
    assert (nlsd.from_string(nlsd.to_string(False)) == False)
Esempio n. 5
0
def test_none():
    assert (nlsd.from_string(nlsd.to_string(None)) == None)
Esempio n. 6
0
def test_list():
    assert (nlsd.from_string(nlsd.to_string([1, 2, 3])) == [1, 2, 3])
Esempio n. 7
0
def test_num():
    assert (nlsd.from_string(nlsd.to_string(1)) == 1)
    assert (nlsd.from_string(nlsd.to_string(1.2)) == 1.2)
    assert (nlsd.from_string(nlsd.to_string(-123)) == -123)
Esempio n. 8
0
def test_string():
    assert (nlsd.from_string(nlsd.to_string("hello")) == "hello")
Esempio n. 9
0
def test_bool():
    assert (nlsd.from_string("true") == True)
    assert (nlsd.from_string("false") == False)
Esempio n. 10
0
def test_none():
    assert (nlsd.from_string("empty") == None)
Esempio n. 11
0
def test_object():
    assert (nlsd.from_string("the object where `a` is 1 and `b` is 2") == {
        "a": 1,
        "b": 2
    })
Esempio n. 12
0
def test_list():
    assert (nlsd.from_string(
        "the list where an item is 1 and another item is 2 and another item is 3"
    ) == [1, 2, 3])
Esempio n. 13
0
def test_num():
    assert (nlsd.from_string("1") == 1)
    assert (nlsd.from_string("1.2") == 1.2)
    assert (nlsd.from_string("-123") == -123)
Esempio n. 14
0
def test_string():
    assert (nlsd.from_string("`hello`") == "hello")