Example #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]
    })
Example #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]
    })
Example #3
0
def test_object():
    assert (nlsd.from_string(nlsd.to_string({
        "a": 1,
        "b": 2
    })) == {
        "a": 1,
        "b": 2
    })
Example #4
0
def test_bool():
    assert (nlsd.from_string(nlsd.to_string(True)) == True)
    assert (nlsd.from_string(nlsd.to_string(False)) == False)
Example #5
0
def test_none():
    assert (nlsd.from_string(nlsd.to_string(None)) == None)
Example #6
0
def test_list():
    assert (nlsd.from_string(nlsd.to_string([1, 2, 3])) == [1, 2, 3])
Example #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)
Example #8
0
def test_string():
    assert (nlsd.from_string(nlsd.to_string("hello")) == "hello")
Example #9
0
def test_bool():
    assert (nlsd.from_string("true") == True)
    assert (nlsd.from_string("false") == False)
Example #10
0
def test_none():
    assert (nlsd.from_string("empty") == None)
Example #11
0
def test_object():
    assert (nlsd.from_string("the object where `a` is 1 and `b` is 2") == {
        "a": 1,
        "b": 2
    })
Example #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])
Example #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)
Example #14
0
def test_string():
    assert (nlsd.from_string("`hello`") == "hello")