Skip to content

Commit

Permalink
Fix unit-test for ABCL
Browse files Browse the repository at this point in the history
Also fix some style errors
  • Loading branch information
yitzchak committed May 20, 2024
1 parent 0a39a14 commit 7c38e15
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
10 changes: 6 additions & 4 deletions code/extrinsic/unit-test/utilities.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
(defun format-eval (&rest args)
(apply #'invistra-extrinsic:format args))

(defun rti (x) x)

(defmacro my-with-standard-io-syntax (&body body)
`(let ((*print-array* t)
(*print-base* 10)
Expand All @@ -27,7 +29,7 @@
,expected
,form))
(macrolet ((fmt (destination control-string &rest args)
`(invistra-extrinsic:format ,destination (progn ,control-string) ,@args)))
`(invistra-extrinsic:format ,destination (rti ,control-string) ,@args)))
(is equal
,expected
,form))))
Expand All @@ -41,7 +43,7 @@
,expected
,form))
(macrolet ((fmt (destination control-string &rest args)
`(invistra-extrinsic:format ,destination (progn ,control-string) ,@args)))
`(invistra-extrinsic:format ,destination (rti ,control-string) ,@args)))
(is equal
,expected
,form)))))
Expand All @@ -54,7 +56,7 @@
,form)
condition)
(fail (macrolet ((fmt (destination control-string &rest args)
`(invistra-extrinsic:format ,destination (progn ,control-string) ,@args)))
`(invistra-extrinsic:format ,destination (rti ,control-string) ,@args)))
,form))))

(defmacro define-argument-fail-test (name form)
Expand All @@ -64,5 +66,5 @@
`(invistra-extrinsic:format ,destination ,control-string ,@args)))
,form))
(fail (macrolet ((fmt (destination control-string &rest args)
`(invistra-extrinsic:format ,destination (progn ,control-string) ,@args)))
`(invistra-extrinsic:format ,destination (rti ,control-string) ,@args)))
,form))))
1 change: 1 addition & 0 deletions code/interface.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
(intern (string name) package))

(defmacro define-interface ((client-var client-class &optional intrinsic) &body body)
(declare (ignore client-class))
(let* ((intrinsic-pkg (if intrinsic (find-package '#:common-lisp) *package*))
(format-func (ensure-symbol '#:format intrinsic-pkg))
(initialize-func (ensure-symbol '#:initialize-invistra)))
Expand Down
2 changes: 0 additions & 2 deletions code/pretty-printer-operations.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@
(setf (function-name directive) (intern symbol-name package)))))

(defmethod interpret-item (client (directive call-function-directive) &optional parameters)
(declare (ignore client))
(apply (coerce-function-designator client (function-name directive))
*destination*
(pop-argument)
Expand All @@ -303,7 +302,6 @@
parameters))

(defmethod compile-item (client (directive call-function-directive) &optional parameters)
(declare (ignore client))
`((funcall (coerce-function-designator ,(incless:client-form client) ',(function-name directive))
*destination*
(pop-argument)
Expand Down
14 changes: 10 additions & 4 deletions code/printer-operations.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"()"
(with-output-to-string (stream)
(incless:write-object client arg stream)))
*destination*
(at-sign-p directive) parameters)))

(defmethod compile-item (client (directive a-directive) &optional parameters)
Expand Down Expand Up @@ -64,7 +65,8 @@
"()"
(with-output-to-string (stream)
(incless:write-object ,(incless:client-form client) arg stream)))
,at-sign-p ,@parameters))))
*destination*
,at-sign-p ,mincol ,colinc ,minpad ,padchar))))
(t
`((let ((*print-escape* nil)
(*print-readably* nil))
Expand All @@ -73,7 +75,8 @@
(incless:write-object ,(incless:client-form client)
(pop-argument)
stream))
,at-sign-p ,@parameters))))))))
*destination*
,at-sign-p ,mincol ,colinc ,minpad ,padchar))))))))

;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
Expand All @@ -99,6 +102,7 @@
"()"
(with-output-to-string (stream)
(incless:write-object client arg stream)))
*destination*
(at-sign-p directive) parameters)))

(defmethod compile-item (client (directive s-directive) &optional parameters)
Expand Down Expand Up @@ -131,15 +135,17 @@
"()"
(with-output-to-string (stream)
(incless:write-object ,(incless:client-form client) arg stream)))
,at-sign-p ,@parameters))))
*destination*
,at-sign-p ,mincol ,colinc ,minpad ,padchar))))
(t
`((let ((*print-escape* t))
(write-string-with-padding
(with-output-to-string (stream)
(incless:write-object ,(incless:client-form client)
(pop-argument)
stream))
,at-sign-p ,@parameters))))))))
*destination*
,at-sign-p ,mincol ,colinc ,minpad ,padchar))))))))

;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
Expand Down
10 changes: 5 additions & 5 deletions code/utilities.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@
(t
(write-char char (target stream)))))))

(defun write-string-with-padding (string pad-left-p mincol colinc minpad padchar)
(defun write-string-with-padding (string stream pad-left-p mincol colinc minpad padchar)
(let ((pad-length (max minpad (* colinc (ceiling (- mincol (length string)) colinc)))))
(if pad-left-p
(loop repeat pad-length
finally (write-string string *destination*)
do (write-char padchar *destination*))
finally (write-string string stream)
do (write-char padchar stream))
(loop repeat pad-length
initially (write-string string *destination*)
do (write-char padchar *destination*)))))
initially (write-string string stream)
do (write-char padchar stream)))))

0 comments on commit 7c38e15

Please sign in to comment.