예제 #1
0
파일: tests.py 프로젝트: a11ce/lispy
def testSubtraction():
    assert (lispy.runProg("(- 5)") == -5)
    assert (lispy.runProg("(- 5 3)") == 2)
    assert (lispy.runProg("(- 5 3 1)") == 1)
예제 #2
0
파일: tests.py 프로젝트: a11ce/lispy
def testLambda():
    assert (lispy.runProg("((lambda (x) (+ x 1)) 3)") == 4)
    assert (lispy.runProg("((lambda () 3))") == 3)
    assert (lispy.runProg("(map (lambda (x) (* x 2)) (list 1 2 3 4))") == [
        2, 4, 6, 8
    ])
예제 #3
0
파일: tests.py 프로젝트: a11ce/lispy
def testDef():
    # TODO temporary global dict for testing
    assert (lispy.runProg("(def x 3)") == 3)
    assert (lispy.runProg("(+ 1 x)") == 4)
    lispy.runProg("(def double (lambda (x) (* x 2)))")
    assert (lispy.runProg("(double x)") == 6)
예제 #4
0
파일: tests.py 프로젝트: a11ce/lispy
def testDivision():
    assert (lispy.runProg("(/ 12 2)") == 6)
    assert (lispy.runProg("(/ 12 2 3)") == 2)
    assert (lispy.runProg("(/ 3)") == 1 / 3)
예제 #5
0
파일: tests.py 프로젝트: a11ce/lispy
def testFunctional():
    assert (lispy.runProg("(foldl + 0 (list 1 2 3))") == 6)
    assert (lispy.runProg("(foldl * 1 (list 1 3 5))") == 15)
    assert (lispy.runProg("(rest (list 1 2))") == [2])
    assert (lispy.runProg("(first (list 1 2))") == 1)
예제 #6
0
파일: tests.py 프로젝트: a11ce/lispy
def testAddition():
    assert (lispy.runProg("(+ 3 2 5 8)") == 18)
    assert (lispy.runProg("(+ 1)") == 1)
    assert (lispy.runProg("(+)") == 0)
예제 #7
0
파일: tests.py 프로젝트: a11ce/lispy
def testSomeBuiltins():
    assert (lispy.runProg("(print 3)") == None)
    assert (lispy.runProg("(sum (list 2 3 1))") == 6)
    assert (lispy.runProg("(abs -1)") == 1)
    assert (lispy.runProg("(len \"foo\")") == 3)
예제 #8
0
파일: tests.py 프로젝트: a11ce/lispy
def testMultiplication():
    assert (lispy.runProg("(* 5 3)") == 15)
    assert (lispy.runProg("(* 5 3 2)") == 30)
    assert (lispy.runProg("(* 5 3)") == 15)
    assert (lispy.runProg("(* 2)") == 2)
    assert (lispy.runProg("(*)") == 1)