Exemple #1
0
def test_ref_within_lazy_function_root():
    prog = OrderedDict()
    prog['a'] = 5
    prog['result'] = foo.lazy(ref('root.a'))
    f = JSONFunction(prog)
    print f()['result']
    assert f()['result'][2] == 5
Exemple #2
0
def test_up_one_leg_down_another():
    d = {'a': {'b': 5}, 'c': {'d': {'e': ref('parent.parent.a.b')}}}

    g = genson.JSONGenerator(d)

    r = g.next()
    assert(r['a']['b'] == r['c']['d']['e'])
Exemple #3
0
def test_ref():
    # XXX This fails because ref's aren't yet implemented with JSONFunction
    # and rec_eval
    prog = OrderedDict()
    prog['a'] = 5
    prog['result'] = foo.lazy(ref('a'))
    f = JSONFunction(prog)
    assert f()['result'][2] == 5