source: trunk/abcl/contrib/jss/jss-tests.lisp @ 14947

Last change on this file since 14947 was 14947, checked in by mevenson, 10 months ago

JSS syntax for fields (Alan Ruttenberg)

<thing> is either {<lisp expression>} or a class name or abbreviation that find-java-class can use

If <thing> is a lisp expression, then it is evaluated (in the lexical environment) and used as an instance
If <thing> is a class name the result of find-java-class is used and a static field access is done.

<field> is either {<lisp expression} or string

If <field> is a lisp expression it should evaluate to a string that names a field
If <field> is a string (no quotes) it is used as the field name

eg. #"foo.bar.baz" -> (get-java-field (find-java-class 'foo.bar) "baz" t)

#"{foo}.baz" -> (get-java-field (find-java-class foo) "baz" t)

From <https://github.com/armedbear/abcl/pull/25/commits/b94639b21843c439a5bf437661446c0b65a67791>.

File size: 438 bytes
Line 
1(in-package :cl-user)
2
3(defpackage jss-test
4  (:use :cl :cl-user :jss :prove))
5
6(in-package :jss-test)
7
8(plan 4)
9
10(is (read-from-string "#\"{bar}.{foo}\"") '(get-java-field bar foo t))
11(is (read-from-string "#\"q.bar.{foo}\"") '(get-java-field (load-time-value (find-java-class "q.bar")) foo t))
12(is (read-from-string "#\"{bar}.foo\"") '(get-java-field bar "foo" t))
13(is-error (read-from-string "#\".bar.foo\"") 'simple-error)
14(finalize)
Note: See TracBrowser for help on using the repository browser.