source: trunk/j/src/org/armedbear/lisp/tests/java-tests.lisp @ 10226

Last change on this file since 10226 was 10226, checked in by piso, 16 years ago

Added tests for JCLASS-OF.

File size: 3.1 KB
Line 
1;;; java-tests.lisp
2;;;
3;;; Copyright (C) 2005 Peter Graves
4;;; $Id: java-tests.lisp,v 1.4 2005-10-25 14:43:49 piso Exp $
5;;;
6;;; This program is free software; you can redistribute it and/or
7;;; modify it under the terms of the GNU General Public License
8;;; as published by the Free Software Foundation; either version 2
9;;; of the License, or (at your option) any later version.
10;;;
11;;; This program is distributed in the hope that it will be useful,
12;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with this program; if not, write to the Free Software
18;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20(unless (member "RT" *modules* :test #'string=)
21  (load "rt-package.lisp")
22  (load #+abcl (compile-file-if-needed "rt.lisp")
23        ;; Force compilation to avoid fasl name conflict between SBCL and
24        ;; Allegro.
25        #-abcl (compile-file "rt.lisp"))
26  (provide "RT"))
27
28;; FIXME
29(load "test-utilities.lisp")
30
31(regression-test:rem-all-tests)
32
33(setf regression-test:*expected-failures* nil)
34
35(unless (find-package '#:test)
36  (defpackage #:test (:use #:cl #:regression-test)))
37
38(in-package #:test)
39
40#+abcl
41(use-package '#:java)
42
43#+allegro
44(require :jlinker)
45#+allegro
46(use-package '#:javatools.jlinker)
47#+allegro
48(use-package '#:javatools.jlinker '#:cl-user) ;; For convenience only.
49#+(and allegro mswindows)
50(use-package '#:javatools.jlinker '#:cg-user) ;; For convenience only.
51#+allegro
52(load "jl-config.cl")
53#+allegro
54(or (jlinker-query) (jlinker-init))
55
56#+abcl
57(deftest java-object.1
58  (class-name (find-class 'java-object nil))
59  java-object)
60
61(deftest jclass-name.1
62  (jclass-name (jclass "java.lang.Object"))
63  "java.lang.Object")
64
65(deftest jclass-name.2
66  (jclass-name (jclass "java.lang.Object") "java.lang.Object")
67  t
68  "java.lang.Object")
69
70(deftest jclass-name.3
71  (jclass-name (jclass "java.lang.Object") "foo")
72  nil
73  "java.lang.Object")
74
75(deftest jclass-of.1
76  (jclass-of "foo")
77  "java.lang.String"
78  "java.lang.String")
79
80(deftest jclass-of.2
81  (jclass-of "foo" "java.lang.String")
82  t
83  "java.lang.String")
84
85(deftest jclass-of.3
86  (jclass-of "foo" "bar")
87  nil
88  "java.lang.String")
89
90(deftest jclass-of.4
91  (jclass-of 42)
92  nil
93  nil)
94
95(deftest jclass-of.5
96  (jclass-of 'foo)
97  nil
98  nil)
99
100(deftest jcall.1
101  (let ((method (jmethod "java.lang.String" "length")))
102    (jcall method "test"))
103  4)
104
105(deftest jcall.2
106  (jcall "length" "test")
107  4)
108
109(deftest jcall.3
110  (let ((method (jmethod "java.lang.String" "regionMatches" 4)))
111    (jcall method "test" 0 "this is a test" 10 4))
112  t)
113
114(deftest jcall.4
115  (let ((method (jmethod "java.lang.String" "regionMatches" 5)))
116    (jcall method "test" (make-immediate-object nil :boolean) 0 "this is a test" 10 4))
117  t)
118
119#-abcl
120(deftest jnew.1
121  (jclass-of (jnew "java.awt.Point") "java.awt.Point")
122  t
123  "java.awt.Point")
124
125(deftest jfield.1
126  (type-of (jfield "java.lang.Integer" "TYPE"))
127  #+abcl    java-object
128  #+allegro tran-struct)
129
130(do-tests)
131
132;;#+allegro
133;;(jlinker-end)
Note: See TracBrowser for help on using the repository browser.