Source Code Cross Referenced for LispValueTest.java in  » Scripting » Jatha » org » jatha » test » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » Jatha » org.jatha.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Jatha - a Common LISP-compatible LISP library in Java.
003:         * Copyright (C) 1997-2005 Micheal Scott Hewett
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018:         *
019:         *
020:         * For further information, please contact Micheal Hewett at
021:         *   hewett@cs.stanford.edu
022:         *
023:         */
024:        /* Copyright (c) 1996, 1997    Micheal Hewett   hewett@cs.stanford.edu
025:         *
026:         * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
027:         *  This source code is copyrighted as shown above.  If this
028:         *  code was obtained as part of a freeware or shareware release,
029:         *  assume that the provisions of the Gnu "copyleft" agreement
030:         *  apply.
031:         * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
032:         *
033:         *        File:  LispValueTest.java
034:         *
035:         *      Author:  Micheal Hewett
036:         *     Created:  13 Jan 1997
037:         *
038:         *    Compiler:  javac 1.0.2
039:         *
040:         * Description:  Test program for the LispValue package
041:         *
042:         ****************************************************************************
043:         *
044:         *  Classes:
045:         *
046:         *     LispValueTest   (has a main() function).
047:         *
048:         *
049:         ****************************************************************************
050:         */
051:
052:        package org.jatha.test;
053:
054:        import java.applet.Applet;
055:        import java.io.IOException;
056:
057:        import org.jatha.Jatha;
058:        import org.jatha.dynatype.LispInteger;
059:        import org.jatha.dynatype.LispReal;
060:        import org.jatha.dynatype.LispString;
061:        import org.jatha.dynatype.LispSymbol;
062:        import org.jatha.dynatype.LispValue;
063:
064:        public class LispValueTest extends Applet {
065:            public static void main(String argv[]) {
066:                LispTester tester = new LispTester();
067:
068:                Jatha lisp = new Jatha(false, false);
069:
070:                lisp.init();
071:                lisp.start();
072:
073:                tester.test(lisp);
074:            }
075:
076:        }
077:
078:        class LispTester {
079:
080:            public void show(String label, LispValue value) {
081:                System.out.print(label);
082:                value.print(); // System.out;
083:                System.out.println();
084:            }
085:
086:            public void test(Jatha lisp) {
087:
088:                // TEST SYMBOLS
089:                LispSymbol x1 = lisp.makeSymbol("Mike");
090:
091:                LispValue l1 = lisp.makeCons(x1, lisp.T);
092:                LispValue l2 = lisp.makeCons(lisp.NIL, l1);
093:
094:                show("L2: ", l2);
095:
096:                LispValue l3 = lisp.makeCons(x1, lisp.NIL);
097:                LispValue l4 = lisp.makeCons(lisp.T, l3);
098:
099:                show("L4: ", l4);
100:
101:                LispValue l5 = lisp.makeCons(x1, lisp.NIL);
102:                LispValue l6 = lisp.makeCons(l3, l1);
103:
104:                show("L6: ", l6);
105:
106:                // TEST Numbers
107:
108:                LispInteger i1 = lisp.makeInteger();
109:                LispInteger i2 = lisp.makeInteger(5);
110:                LispInteger i3 = lisp.makeInteger(273);
111:
112:                LispValue l7 = lisp.makeCons(i3, lisp.makeList(i2, i1));
113:                show("L7: ", l7);
114:
115:                LispReal r1 = lisp.makeReal();
116:                LispReal r2 = lisp.makeReal(5.5);
117:                LispReal r3 = lisp.makeReal(273.273273);
118:
119:                LispValue l8 = lisp.makeList(r3, r2, r1);
120:                show("L8: ", l8);
121:
122:                // TEST Strings
123:
124:                LispString s1 = lisp.makeString("BAZ");
125:                LispString s2 = lisp.makeString("bar");
126:                LispString s3 = lisp.makeString("foo");
127:
128:                LispValue l9 = lisp.makeCons(s3, lisp.makeCons(s2, lisp
129:                        .makeCons(s1, lisp.makeList(r3, r2, r1))));
130:                show("L9: ", l9);
131:
132:                LispValue l10 = lisp.makeList(s3, s2);
133:                show("L10: ", l10);
134:
135:                // Added 23 Feb 2006 (mh)
136:                //    try {
137:                //      String expr = "(* 5 B)";
138:                //      LispValue a = lisp.makeSymbol("A");
139:                //      a.set_special(true);
140:                //      a.setf_symbol_value(lisp.makeInteger(7));
141:                //      System.out.println("A = " + a.symbol_value());
142:                //
143:                //      LispValue B       = lisp.eval("B");
144:                //      LispValue globals = lisp.makeList(lisp.makeList(lisp.makeCons(lisp.makeSymbol("B"), lisp.makeInteger(7))));
145:                //      LispValue input  = lisp.parse(expr);
146:                //      LispValue result = lisp.eval(input, globals);
147:                //      System.out.println(input + " = " + result);
148:                //    } catch (IOException ioe) {
149:                //      System.err.println("Exception during test ");
150:                //    }
151:
152:                // Test #1
153:                System.out.println(lisp.eval("(let ((x 7)) (* 5 x)))"));
154:                System.out.println(lisp.eval("(progn (setq x 7) (* 5 x))"));
155:                System.out.println(lisp.eval("(setq x 7)"));
156:                System.out.println(lisp.eval("(* 5 x)"));
157:
158:                // Test #2
159:                try {
160:                    String expr = "(let ((x 7)) (* 5 x)))";
161:                    LispValue input = lisp.parse(expr);
162:                    LispValue result = lisp.eval(input);
163:                    System.out.println(input + " = " + result);
164:                } catch (IOException ioe) {
165:                    System.err.println("Exception during test ");
166:                }
167:
168:            }
169:        }
170:
171:        /*
172:
173:         void
174:         cSimbaApp::test_lisp_functions(void)
175:         {
176:         // Test LISP functions
177:
178:         LispString str1 = new LispString("testing");
179:         cout << (char )(str1) << endl;
180:
181:         cout << "Mike = " << (long)(intern("Mike")) << endl;
182:         cout << "Mike = " << (long)(intern("Mike")) << endl;
183:
184:         LispValue aList = list(3, lisp.makeCons(intern("Mike"),   makeInteger(38)),
185:         lisp.makeCons(intern("Allie"),  makeInteger(4)),
186:         lisp.makeCons(intern("Sowmya"), makeInteger(29)));
187:         cout << "ALIST = " << aList << endl;
188:
189:         LispValue value = assoc(intern("Mike"), aList);
190:         cout << "Assoc returned: " << value << endl;
191:
192:         LispValue list4 = list(5, intern("Alpha"), intern("Beta"), intern("Delta"), intern("Gamma"), intern("Zeta"));
193:         cout << "Member(Beta) returned: " << (member(intern("Beta"), list4)) << endl;
194:         cout << "Member(Tau) returned: "  << (member(intern("Tau"), list4)) << endl;
195:
196:         cout << "remove(Beta) returned: " << (remove(intern("Beta"), list4)) << endl;
197:         cout << "remove(Tau) returned: "  << (remove(intern("Tau"), list4)) << endl;
198:
199:         cout << "remove(Alpha) returned: " << (remove(intern("Alpha"), list4)) << endl;
200:         cout << "remove(Zeta) returned: "  << (remove(intern("Zeta"), list4)) << endl;
201:
202:         cout << "subst(Delta, Mike)  returned: " << (subst(intern("Delta"), intern("Mike"), list4)) << endl;
203:         cout << "subst(Foo, Mike)    returned: " << (subst(intern("Foo"), intern("Mike"), list4)) << endl;
204:         cout << "subst(Gamma, Allie) returned: " << (subst(intern("Gamma"), intern("Allie"), list4)) << endl;
205:
206:         }
207:
208:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.