-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JAVAPARSER now "stacks" its macro definition on the existing one it inherits from JSS. Refactor all tests to just pollute CL-USER where necessary (strictly speaking it shouldn't be necessary as all PROVE tests should be able to use lexical bindings. Document existence of Java field access via SHARPSIGN-QUOTATION_MARK, e.g. (#"{java.lang.System}.{fileSeparator}") and the new Java DSL (asdf:make :javaparser) (#"'#1"new ByteBuddy() .subclass(Object.class,t) .method(ElementMatchers.named("toString")) .intercept(FixedValue.value("Hello World!")) .make() .load(getClass().getClassLoader()) .getLoaded()"
- Loading branch information
mevenson@1c010e3e-69d0-11dd-93a8-456734b0d56f
committed
Jun 9, 2017
1 parent
64203af
commit 80f8222
Showing
5 changed files
with
83 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,67 @@ | ||
(in-package :cl-user) | ||
|
||
(defpackage jss-test | ||
(:use :cl :cl-user :jss :prove)) | ||
(prove:plan 6) | ||
|
||
(in-package :jss-test) | ||
|
||
(plan 6) | ||
|
||
(is (read-from-string "#\"{bar}.{foo}\"") '(get-java-field bar foo t)) | ||
(is (read-from-string "#\"q.bar.{foo}\"") '(get-java-field (load-time-value (find-java-class "q.bar")) foo t)) | ||
(is (read-from-string "#\"{bar}.foo\"") '(get-java-field bar "foo" t)) | ||
(is-error (read-from-string "#\".bar.foo\"") 'simple-error) | ||
(prove:is | ||
(read-from-string "#\"{bar}.{foo}\"") | ||
'(get-java-field bar foo t)) | ||
(prove:is | ||
(read-from-string "#\"q.bar.{foo}\"") | ||
'(get-java-field (load-time-value (find-java-class "q.bar")) foo t)) | ||
(prove:is | ||
(read-from-string "#\"{bar}.foo\"") | ||
'(get-java-field bar "foo" t)) | ||
(prove:is-error | ||
(read-from-string "#\".bar.foo\"") | ||
'simple-error) | ||
;;; http://abcl.org/trac/ticket/205 | ||
(is (with-constant-signature ((substring "substring")) (substring "01234" 2)) "234") | ||
(prove:is | ||
(with-constant-signature ((substring "substring")) | ||
(substring "01234" 2)) "234") | ||
;;; http://abcl.org/trac/ticket/229 - note: version of test for this ticket was broken in tests.lisp | ||
(is (#"toString" (find "size" | ||
(#"getMethods" (find-java-class "java.util.Collections$UnmodifiableMap")) | ||
:test 'string-equal :key #"getName")) | ||
(prove:is (#"toString" | ||
(find "size" (#"getMethods" (find-java-class "java.util.Collections$UnmodifiableMap")) | ||
:test 'string-equal :key #"getName")) | ||
(#"toString" (java::jmethod "java.util.Collections$UnmodifiableMap" "size" ))) | ||
|
||
;; test that optimized jss is much faster than unoptimized | ||
(defun optimized-jss (count) | ||
(loop repeat count do (#"compile" 'regex.Pattern ".*"))) | ||
|
||
(let ((jss::*inhibit-jss-optimization* t)) | ||
(defun unoptimized-jss (count) | ||
(loop repeat count do (#"compile" 'regex.Pattern ".*")))) | ||
|
||
(defun just-loop (count) | ||
(loop repeat count)) | ||
|
||
(let ((jss::*inhibit-jss-optimization* nil)) | ||
(compile 'just-loop) | ||
(compile 'optimized-jss)) | ||
(let ((jss::*inhibit-jss-optimization* t)) | ||
(compile 'unoptimized-jss)) | ||
|
||
(defmacro timeit (&body body) | ||
`(let ((start (#"currentTimeMillis" 'system))) | ||
,@body | ||
(- (#"currentTimeMillis" 'system) start))) | ||
(let () | ||
(defun optimized-jss (count) | ||
(loop repeat count do (#"compile" 'regex.Pattern ".*"))) | ||
(let ((jss::*inhibit-jss-optimization* t)) | ||
(defun unoptimized-jss (count) | ||
(loop repeat count do (#"compile" 'regex.Pattern ".*")))) | ||
(defun just-loop (count) | ||
(loop repeat count)) | ||
(let ((jss::*inhibit-jss-optimization* nil)) | ||
(compile 'just-loop) | ||
(compile 'optimized-jss)) | ||
(let ((jss::*inhibit-jss-optimization* t)) | ||
(compile 'unoptimized-jss)) | ||
|
||
(defmacro timeit (&body body) | ||
`(let ((start (#"currentTimeMillis" 'system))) | ||
,@body | ||
(- (#"currentTimeMillis" 'system) start))) | ||
|
||
(plan 1) | ||
(is-type (let ((just-loop (timeit (just-loop 10000)))) | ||
(prove:plan 1) | ||
(prove:is-type (let ((just-loop (timeit (just-loop 10000)))) | ||
(+ 0.0 | ||
(/ (- (timeit (optimized-jss 10000)) just-loop) | ||
(- (timeit (unoptimized-jss 10000)) just-loop)))) | ||
'(float 0 0.1)) | ||
'(float 0 0.1) | ||
"Testing JSS compiler optimization…")) | ||
|
||
(plan 2) | ||
(prove:plan 2) | ||
(let* ((jss::*inhibit-jss-optimization* nil) | ||
(optimized-jss (macroexpand (precompiler::precompile-form '(#"compile" 'regex.Pattern ".*") t)))) | ||
(optimized-jss | ||
(macroexpand (precompiler::precompile-form | ||
'(#"compile" 'regex.Pattern ".*") t)))) | ||
(let* ((jss::*inhibit-jss-optimization* t) | ||
(unoptimized-jss (macroexpand (precompiler::precompile-form '(#"compile" 'regex.Pattern ".*") t)))) | ||
(is (car optimized-jss) 'java:jstatic) | ||
(is (caar unoptimized-jss) 'lambda))) | ||
(unoptimized-jss | ||
(macroexpand (precompiler::precompile-form '(#"compile" 'regex.Pattern ".*") t)))) | ||
(prove:is (car optimized-jss) 'java:jstatic) | ||
(prove:is (caar unoptimized-jss) 'lambda))) | ||
|
||
(finalize) | ||
(prove:finalize) | ||
|