def test_power_staged(): assert ( lmscompile(lambda x: power1(x, 3)).code == "['begin', ['let', x0, ['*', in, 1]], ['let', x1, ['*', in, x0]], ['let', x2, ['*', in, x1]], x2]" ) assert ( lmscompile(lambda x: power2(x, 3)).code == "['begin', ['let', x0, ['*', in, 1]], ['let', x1, ['*', in, x0]], ['let', x2, ['*', in, x1]], x2]" )
def test_foobar1_staged(): assert(lmscompile(foobar1).code == """ ['begin', ['let', x0, ['==', in, 0]], ['let', x1, ['if', x0, ['begin', ['let', x1, ['print', '"yes"']], None], ['begin', ['let', x1, ['print', '"no"']], None]]], in] """.replace('\n','').replace(' ',' ').replace(' ',' '))
def test_loop1_staged(): assert (lmscompile(loop1).code == """ ['begin', ['let', x7, ['new']], ['let', x8, ['set', x7, 0]], ['let', x9, ['get', x7]], ['let', x10, ['<', x9, in]], ['let', x11, ['while', ['begin', ['let', x11, ['get', x7]], ['let', x12, ['<', x11, in]], x12], ['begin', ['let', x11, ['get', x7]], ['let', x12, ['+', x11, 1]], ['let', x13, ['set', x7, x12]], None]]], ['let', x12, ['get', x7]], x12] """.replace('\n', '').replace(' ', ' ').replace(' ', ' ').replace(' ', ' '))
def test_foobar1(): assert lmscompile(lambda _: foobar1(7)).code == """['begin', 7]"""
def test_foobar2_staged(): assert ( lmscompile(foobar2).code == """['begin', ['let', x0, ['==', in, 0]], ['let', x1, ['if', x0, ['begin', 'yes'], ['begin', 'no']]], x1]""" )
def test_foobar1(): assert(lmscompile(lambda _: foobar1(7)).code == """['begin', ['let', x0, ['print', '"no"']], 7]""")