Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
ansi-test
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michał Herda
ansi-test
Commits
0f906ffb
Commit
0f906ffb
authored
22 years ago
by
pfdietz
Browse files
Options
Downloads
Patches
Plain Diff
Added more binary formats to .cvsignore. Added more structure tests.
parent
a7f30878
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ansi-tests/structure-00.lsp
+29
-13
29 additions, 13 deletions
ansi-tests/structure-00.lsp
ansi-tests/structures-02.lsp
+33
-0
33 additions, 0 deletions
ansi-tests/structures-02.lsp
with
62 additions
and
13 deletions
ansi-tests/structure-00.lsp
+
29
−
13
View file @
0f906ffb
...
@@ -33,11 +33,14 @@
...
@@ -33,11 +33,14 @@
(defun make-struct-field-fn (conc-name field-name)
(defun make-struct-field-fn (conc-name field-name)
"Make field accessor for a field in a structure"
"Make field accessor for a field in a structure"
(assert (typep conc-name '(or string symbol character)))
(cond
(assert (typep field-name '(or string symbol character)))
((null conc-name) field-name)
(setf conc-name (string conc-name))
(t
(setf field-name (string field-name))
(assert (typep conc-name '(or string symbol character)))
(intern (concatenate 'string conc-name field-name)))
(assert (typep field-name '(or string symbol character)))
(setf conc-name (string conc-name))
(setf field-name (string field-name))
(intern (concatenate 'string conc-name field-name)))))
(defun make-struct-make-fn (structure-name)
(defun make-struct-make-fn (structure-name)
"Make the make- function for a structure"
"Make the make- function for a structure"
...
@@ -136,6 +139,7 @@ do the defstruct."
...
@@ -136,6 +139,7 @@ do the defstruct."
(name (if (consp name-and-options)
(name (if (consp name-and-options)
(car name-and-options)
(car name-and-options)
name-and-options))
name-and-options))
;; The options list, or NIL if there were no options
;; The options list, or NIL if there were no options
(options (if (consp name-and-options)
(options (if (consp name-and-options)
(cdr name-and-options)
(cdr name-and-options)
...
@@ -165,6 +169,12 @@ do the defstruct."
...
@@ -165,6 +169,12 @@ do the defstruct."
;; Symbol obtained by prepending MAKE- to the name symbol
;; Symbol obtained by prepending MAKE- to the name symbol
(make-fn (make-struct-make-fn name))
(make-fn (make-struct-make-fn name))
;; The type option, if specified
(type-option (find-option options :type))
(struct-type (second type-option))
(named-option (find-option options :named))
;; The :predicate option entry from OPTIONS, or NIL if none
;; The :predicate option entry from OPTIONS, or NIL if none
(predicate-option (find-option options :predicate))
(predicate-option (find-option options :predicate))
...
@@ -172,6 +182,7 @@ do the defstruct."
...
@@ -172,6 +182,7 @@ do the defstruct."
;; one specified in the :predicate option
;; one specified in the :predicate option
(p-fn-default (make-struct-p-fn name))
(p-fn-default (make-struct-p-fn name))
(p-fn (cond
(p-fn (cond
((and type-option (not named-option)) nil)
((or (eq predicate-option :predicate)
((or (eq predicate-option :predicate)
(null (cdr predicate-option)))
(null (cdr predicate-option)))
p-fn-default)
p-fn-default)
...
@@ -194,16 +205,18 @@ do the defstruct."
...
@@ -194,16 +205,18 @@ do the defstruct."
(conc-option (find-option options :conc-name))
(conc-option (find-option options :conc-name))
;; String to be prepended to slot names to get the
;; String to be prepended to slot names to get the
;; slot accessor function
;; slot accessor function
(conc-prefix-default
(conc-prefix-default (concatenate 'string (string name) "-"))
(concatenate 'string (string name) "-"))
(conc-prefix (cond
(conc-prefix (cond
((null conc-option)
((null conc-option)
conc-prefix-default)
conc-prefix-default)
((or (eq conc-option :conc-name)
((or (eq conc-option :conc-name)
(null (cadr conc-option)))
(null (cadr conc-option)))
""
)
nil
)
(t (string (cadr conc-option)))))
(t (string (cadr conc-option)))))
(initial-offset-option (find-option options :initial-offset))
(initial-offset (second initial-offset-option))
;; Accessor names
;; Accessor names
(field-fns
(field-fns
(loop for slot-name in slot-names
(loop for slot-name in slot-names
...
@@ -230,7 +243,9 @@ do the defstruct."
...
@@ -230,7 +243,9 @@ do the defstruct."
(and (fboundp (quote ,make-fn))
(and (fboundp (quote ,make-fn))
(functionp (function ,make-fn))
(functionp (function ,make-fn))
(symbol-function (quote ,make-fn))
(symbol-function (quote ,make-fn))
(notnot (typep (,make-fn) (quote ,name))))
,@(unless type-option
`((typep (,make-fn) (quote ,name))))
t)
t)
t)
;; Test that the predicate exists
;; Test that the predicate exists
...
@@ -249,10 +264,11 @@ do the defstruct."
...
@@ -249,10 +264,11 @@ do the defstruct."
(count-if (function ,p-fn) *universe*)
(count-if (function ,p-fn) *universe*)
0)))
0)))
(deftest ,(make-struct-test-name name 4)
,@(unless type-option
(count-if (function (lambda (x) (typep x (quote ,name))))
`((deftest ,(make-struct-test-name name 4)
*universe*)
(count-if (function (lambda (x) (typep x (quote ,name))))
0)
*universe*)
0)))
;; Check that the fields can be read after being initialized
;; Check that the fields can be read after being initialized
(deftest ,(make-struct-test-name name 5)
(deftest ,(make-struct-test-name name 5)
...
...
This diff is collapsed.
Click to expand it.
ansi-tests/structures-02.lsp
+
33
−
0
View file @
0f906ffb
...
@@ -175,6 +175,39 @@
...
@@ -175,6 +175,39 @@
(b29 'xx :read-only 1)
(b29 'xx :read-only 1)
c29)
c29)
(defstruct-with-tests struct-test-30 #:a30 #:b30)
(defstruct-with-tests #:struct-test-31 a31 b31)
(defpackage struct-test-package (:use))
(defstruct-with-tests struct-test-32
struct-test-package::a32 struct-test-package::b32)
;;; If the :conc-name option is given no argument or
;;; a nil argument, the accessor names are the same as
;;; slot names. Note that this is different from prepending
;;; an empty string, since that may get you a name in
;;; a different package.
(defstruct-with-tests (struct-test-33 (:conc-name))
struct-test-package::a33 struct-test-package::b33)
(defstruct-with-tests (struct-test-34 :conc-name)
struct-test-package::a34 struct-test-package::b34)
(defstruct-with-tests (struct-test-35 (:conc-name nil))
struct-test-package::a35 struct-test-package::b35)
(defstruct-with-tests (struct-test-36 (:conc-name ""))
struct-test-package::st36-a36 struct-test-package::st26-b36)
;;; List structures
(defstruct-with-tests (struct-test-37 (:type list)) a37 b37 c37)
(defstruct-with-tests (struct-test-38 (:type list) :named) a38 b38 c38)
(defstruct-with-tests (struct-test-39 (:predicate nil)
(:type list) :named)
a39 b39 c39)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment