From d4a8ea01767e064d58a7bfb9a9959d1c356b7d79 Mon Sep 17 00:00:00 2001 From: eric567 Date: Tue, 12 Jul 2016 08:06:59 +0800 Subject: [PATCH] add test case for LispCompiler --- .../java/com/github/eric/LispComplierTest.groovy | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/github/eric/LispComplierTest.groovy b/src/test/java/com/github/eric/LispComplierTest.groovy index 90d2bd7..91c99ee 100644 --- a/src/test/java/com/github/eric/LispComplierTest.groovy +++ b/src/test/java/com/github/eric/LispComplierTest.groovy @@ -18,7 +18,7 @@ class LispComplierTest extends Specification { } - def "Eval"() { + def "Eval 1,(+ 1 2 )"() { given:"valuepair1 instance with 1,2,valuepair2 with + ,valuepair1" ValuePair vp1=new ValuePair(1,2) ValuePair vp2=new ValuePair("+",vp1) @@ -29,4 +29,17 @@ class LispComplierTest extends Specification { rt_int==3 } + + def "Eval 2,(+ 1 2 3)"() { + given:"valuepari3 with 3,null valuepair1 instance with 1,2,valuepair2 with + ,valuepair1,valuepari3" + ValuePair vp3=new ValuePair(2,3) + ValuePair vp1=new ValuePair(1,vp3) + ValuePair vp2=new ValuePair("+",vp1) + when:"call the mathod eval with valuepair2" + Object rt=LispComplier.eval(vp2) + int rt_int=Integer.valueOf(rt) + then:"the result shall be 3" + rt_int==6 + + } }