clucumber 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data/LICENSE +1 -1
  2. data/README.md +4 -9
  3. data/lib/clucumber/clucumber-bootstrap.lisp +32 -0
  4. data/lib/clucumber/vendor/cl-interpol/alias.lisp +55 -0
  5. data/lib/clucumber/vendor/cl-interpol/cl-interpol.asd +56 -0
  6. data/lib/clucumber/vendor/cl-interpol/load.lisp +53 -0
  7. data/lib/clucumber/vendor/cl-interpol/packages.lisp +40 -0
  8. data/lib/clucumber/vendor/cl-interpol/read.lisp +716 -0
  9. data/lib/clucumber/vendor/cl-interpol/specials.lisp +113 -0
  10. data/lib/clucumber/vendor/cl-interpol/test/packages.lisp +34 -0
  11. data/lib/clucumber/vendor/cl-interpol/test/tests.lisp +128 -0
  12. data/lib/clucumber/vendor/cl-interpol/test.lisp +177 -0
  13. data/lib/clucumber/vendor/cl-interpol/test2.lisp +6254 -0
  14. data/lib/clucumber/vendor/cl-interpol/unicode.lisp +13912 -0
  15. data/lib/clucumber/vendor/cl-interpol/util.lisp +122 -0
  16. data/lib/clucumber/vendor/cl-ppcre/api.lisp +1262 -0
  17. data/lib/clucumber/vendor/cl-ppcre/charmap.lisp +152 -0
  18. data/lib/clucumber/vendor/cl-ppcre/charset.lisp +242 -0
  19. data/lib/clucumber/vendor/cl-ppcre/chartest.lisp +98 -0
  20. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-test.asd +34 -0
  21. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-unicode/packages.lisp +38 -0
  22. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-unicode/resolver.lisp +61 -0
  23. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-unicode.asd +58 -0
  24. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre.asd +79 -0
  25. data/lib/clucumber/vendor/cl-ppcre/closures.lisp +471 -0
  26. data/lib/clucumber/vendor/cl-ppcre/convert.lisp +875 -0
  27. data/lib/clucumber/vendor/cl-ppcre/errors.lisp +84 -0
  28. data/lib/clucumber/vendor/cl-ppcre/lexer.lisp +737 -0
  29. data/lib/clucumber/vendor/cl-ppcre/lispworks-defsystem.lisp +57 -0
  30. data/lib/clucumber/vendor/cl-ppcre/load.lisp +67 -0
  31. data/lib/clucumber/vendor/cl-ppcre/optimize.lisp +578 -0
  32. data/lib/clucumber/vendor/cl-ppcre/packages.lisp +68 -0
  33. data/lib/clucumber/vendor/cl-ppcre/parser.lisp +319 -0
  34. data/lib/clucumber/vendor/cl-ppcre/ppcre-tests.lisp +269 -0
  35. data/lib/clucumber/vendor/cl-ppcre/regex-class-util.lisp +555 -0
  36. data/lib/clucumber/vendor/cl-ppcre/regex-class.lisp +259 -0
  37. data/lib/clucumber/vendor/cl-ppcre/repetition-closures.lisp +833 -0
  38. data/lib/clucumber/vendor/cl-ppcre/scanner.lisp +506 -0
  39. data/lib/clucumber/vendor/cl-ppcre/specials.lisp +172 -0
  40. data/lib/clucumber/vendor/cl-ppcre/test/packages.lisp +37 -0
  41. data/lib/clucumber/vendor/cl-ppcre/test/perl-tests.lisp +150 -0
  42. data/lib/clucumber/vendor/cl-ppcre/test/tests.lisp +159 -0
  43. data/lib/clucumber/vendor/cl-ppcre/test/unicode-tests.lisp +80 -0
  44. data/lib/clucumber/vendor/cl-ppcre/util.lisp +201 -0
  45. data/lib/clucumber/vendor/cl-unicode/alias.lisp +135 -0
  46. data/lib/clucumber/vendor/cl-unicode/api.lisp +412 -0
  47. data/lib/clucumber/vendor/cl-unicode/build/char-info.lisp +133 -0
  48. data/lib/clucumber/vendor/cl-unicode/build/dump.lisp +239 -0
  49. data/lib/clucumber/vendor/cl-unicode/build/read.lisp +280 -0
  50. data/lib/clucumber/vendor/cl-unicode/build/util.lisp +182 -0
  51. data/lib/clucumber/vendor/cl-unicode/cl-unicode.asd +90 -0
  52. data/lib/clucumber/vendor/cl-unicode/conditions.lisp +54 -0
  53. data/lib/clucumber/vendor/cl-unicode/derived.lisp +120 -0
  54. data/lib/clucumber/vendor/cl-unicode/hash-tables.lisp +20 -0
  55. data/lib/clucumber/vendor/cl-unicode/lists.lisp +10 -0
  56. data/lib/clucumber/vendor/cl-unicode/methods.lisp +15 -0
  57. data/lib/clucumber/vendor/cl-unicode/packages.lisp +76 -0
  58. data/lib/clucumber/vendor/cl-unicode/specials.lisp +135 -0
  59. data/lib/clucumber/vendor/cl-unicode/test/packages.lisp +34 -0
  60. data/lib/clucumber/vendor/cl-unicode/test/tests.lisp +150 -0
  61. data/lib/clucumber/vendor/cl-unicode/test-functions.lisp +94 -0
  62. data/lib/clucumber/vendor/cl-unicode/util.lisp +274 -0
  63. data/lib/clucumber/vendor/lift/compare/fiveam-tests.lisp +14 -0
  64. data/lib/clucumber/vendor/lift/compare/lift-tests.lisp +13 -0
  65. data/lib/clucumber/vendor/lift/compare/rt-tests.lisp +16 -0
  66. data/lib/clucumber/vendor/lift/compare/xlunit-tests.lisp +15 -0
  67. data/lib/clucumber/vendor/lift/dev/changes.lisp +61 -0
  68. data/lib/clucumber/vendor/lift/dev/config.lisp +354 -0
  69. data/lib/clucumber/vendor/lift/dev/copy-file.lisp +117 -0
  70. data/lib/clucumber/vendor/lift/dev/introspection.lisp +232 -0
  71. data/lib/clucumber/vendor/lift/dev/lift-interface.lisp +56 -0
  72. data/lib/clucumber/vendor/lift/dev/lift-notes.lisp +202 -0
  73. data/lib/clucumber/vendor/lift/dev/lift-randomized.lisp +45 -0
  74. data/lib/clucumber/vendor/lift/dev/lift.lisp +2383 -0
  75. data/lib/clucumber/vendor/lift/dev/macros.lisp +229 -0
  76. data/lib/clucumber/vendor/lift/dev/measuring.lisp +156 -0
  77. data/lib/clucumber/vendor/lift/dev/packages.lisp +161 -0
  78. data/lib/clucumber/vendor/lift/dev/port.lisp +151 -0
  79. data/lib/clucumber/vendor/lift/dev/prototypes.lisp +282 -0
  80. data/lib/clucumber/vendor/lift/dev/random-testing.lisp +124 -0
  81. data/lib/clucumber/vendor/lift/dev/report-locations.lisp +13 -0
  82. data/lib/clucumber/vendor/lift/dev/reports.lisp +916 -0
  83. data/lib/clucumber/vendor/lift/dev/utilities.lisp +242 -0
  84. data/lib/clucumber/vendor/lift/docs/package.lisp +6 -0
  85. data/lib/clucumber/vendor/lift/docs/setup.lisp +17 -0
  86. data/lib/clucumber/vendor/lift/examples/basic-examples.lisp +289 -0
  87. data/lib/clucumber/vendor/lift/examples/random-testing.lisp +32 -0
  88. data/lib/clucumber/vendor/lift/lift-documentation.asd +28 -0
  89. data/lib/clucumber/vendor/lift/lift-test.asd +35 -0
  90. data/lib/clucumber/vendor/lift/lift.asd +77 -0
  91. data/lib/clucumber/vendor/lift/test/equality-tests.lisp +40 -0
  92. data/lib/clucumber/vendor/lift/test/finding-tests.lisp +32 -0
  93. data/lib/clucumber/vendor/lift/test/lift-test.lisp +783 -0
  94. data/lib/clucumber/vendor/lift/test/order-of-operations.lisp +54 -0
  95. data/lib/clucumber/vendor/lift/test/packages.lisp +17 -0
  96. data/lib/clucumber/vendor/lift/test/test-config-files.lisp +20 -0
  97. data/lib/clucumber/vendor/lift/test/test-dynamic-variables.lisp +57 -0
  98. data/lib/clucumber/vendor/lift/test/test-maximum-problems.lisp +74 -0
  99. data/lib/clucumber/vendor/lift/test/test-prototypes.lisp +278 -0
  100. data/lib/clucumber/vendor/lift/test/test-timeout.lisp +37 -0
  101. data/lib/clucumber/vendor/lift/test/tests-in-progress.lisp +62 -0
  102. data/lib/clucumber/vendor/lift/test/testsuite-expects.lisp +60 -0
  103. data/lib/clucumber/vendor/lift/timeout/package.lisp +13 -0
  104. data/lib/clucumber/vendor/lift/timeout/with-timeout.lisp +123 -0
  105. data/lib/clucumber/vendor/lift/website/stuff/Temp.lisp +34 -0
  106. data/lib/clucumber/vendor/st-json/st-json.asd +3 -0
  107. data/lib/clucumber/vendor/st-json/st-json.lisp +310 -0
  108. data/lib/clucumber/vendor/trivial-backtrace/dev/backtrace.lisp +127 -0
  109. data/lib/clucumber/vendor/trivial-backtrace/dev/fallback.lisp +10 -0
  110. data/lib/clucumber/vendor/trivial-backtrace/dev/map-backtrace.lisp +103 -0
  111. data/lib/clucumber/vendor/trivial-backtrace/dev/mucking.lisp +75 -0
  112. data/lib/clucumber/vendor/trivial-backtrace/dev/packages.lisp +13 -0
  113. data/lib/clucumber/vendor/trivial-backtrace/dev/utilities.lisp +104 -0
  114. data/lib/clucumber/vendor/trivial-backtrace/test/packages.lisp +5 -0
  115. data/lib/clucumber/vendor/trivial-backtrace/test/test-setup.lisp +4 -0
  116. data/lib/clucumber/vendor/trivial-backtrace/test/tests.lisp +16 -0
  117. data/lib/clucumber/vendor/trivial-backtrace/trivial-backtrace-test.asd +22 -0
  118. data/lib/clucumber/vendor/trivial-backtrace/trivial-backtrace.asd +35 -0
  119. data/lib/clucumber/vendor/usocket/backend/allegro.lisp +199 -0
  120. data/lib/clucumber/vendor/usocket/backend/armedbear.lisp +491 -0
  121. data/lib/clucumber/vendor/usocket/backend/clisp.lisp +260 -0
  122. data/lib/clucumber/vendor/usocket/backend/cmucl.lisp +266 -0
  123. data/lib/clucumber/vendor/usocket/backend/lispworks.lisp +741 -0
  124. data/lib/clucumber/vendor/usocket/backend/mcl.lisp +369 -0
  125. data/lib/clucumber/vendor/usocket/backend/openmcl.lisp +206 -0
  126. data/lib/clucumber/vendor/usocket/backend/sbcl.lisp +424 -0
  127. data/lib/clucumber/vendor/usocket/backend/scl.lisp +261 -0
  128. data/lib/clucumber/vendor/usocket/condition.lisp +227 -0
  129. data/lib/clucumber/vendor/usocket/package.lisp +82 -0
  130. data/lib/clucumber/vendor/usocket/server.lisp +45 -0
  131. data/lib/clucumber/vendor/usocket/test/package.lisp +13 -0
  132. data/lib/clucumber/vendor/usocket/test/test-usocket.lisp +166 -0
  133. data/lib/clucumber/vendor/usocket/usocket-test.asd +26 -0
  134. data/lib/clucumber/vendor/usocket/usocket.asd +37 -0
  135. data/lib/clucumber/vendor/usocket/usocket.lisp +542 -0
  136. data/lib/clucumber/vendor/usocket/vendor/kqueue.lisp +1 -0
  137. data/lib/clucumber/vendor/usocket/vendor/split-sequence.lisp +245 -0
  138. data/lib/clucumber.rb +29 -7
  139. metadata +151 -5
@@ -0,0 +1,242 @@
1
+ (in-package #:lift)
2
+
3
+ ;; stolen from metatilities
4
+ (defun form-symbol-in-package (package &rest names)
5
+ "Finds or interns a symbol in package whose name is formed by concatenating the pretty printed representation of the names together."
6
+ (with-standard-io-syntax
7
+ (let ((*package* package))
8
+ (intern (format nil "~{~a~}" names)
9
+ package))))
10
+
11
+ (defun form-symbol (&rest names)
12
+ "Finds or interns a symbol in the current package whose name is formed by concatenating the pretty printed representation of the names together."
13
+ (apply #'form-symbol-in-package *package* names))
14
+
15
+ (defun form-keyword (&rest names)
16
+ "Finds or interns a symbol in the current package whose name is formed by concatenating the pretty printed representation of the names together."
17
+ (apply #'form-symbol-in-package
18
+ (load-time-value (find-package :keyword)) names))
19
+
20
+ ;; borrowed from asdf
21
+ (defun pathname-sans-name+type (pathname)
22
+ "Returns a new pathname with same HOST, DEVICE, DIRECTORY as PATHNAME,
23
+ and NIL NAME and TYPE components"
24
+ (make-pathname :name nil :type nil :defaults pathname))
25
+
26
+ (defun pathname-has-device-p (pathname)
27
+ (and (or (stringp pathname) (pathnamep pathname))
28
+ (not (member (pathname-device pathname) '(nil :unspecific)))))
29
+
30
+ (defun pathname-has-host-p (pathname)
31
+ (and (or (stringp pathname) (pathnamep pathname))
32
+ (not (member (pathname-host pathname) '(nil :unspecific)))))
33
+
34
+ (defun relative-pathname (relative-to pathname &key name type)
35
+ (let ((directory (pathname-directory pathname)))
36
+ (when (eq (car directory) :absolute)
37
+ (setf directory (copy-list directory)
38
+ (car directory) :relative))
39
+ (merge-pathnames
40
+ (make-pathname :name (or name (pathname-name pathname))
41
+ :type (or type (pathname-type pathname))
42
+ :directory directory
43
+ )
44
+ relative-to)))
45
+
46
+ (defun directory-pathname-p (p)
47
+ (flet ((component-present-p (value)
48
+ (and value (not (eql value :unspecific)))))
49
+ (and
50
+ (not (component-present-p (pathname-name p)))
51
+ (not (component-present-p (pathname-type p)))
52
+ p)))
53
+
54
+ (defun directory-p (name)
55
+ (let ((truename (probe-file name)))
56
+ (and truename (directory-pathname-p name))))
57
+
58
+ (defun containing-pathname (pathspec)
59
+ "Return the containing pathname of the thing to which
60
+ pathspac points. For example:
61
+
62
+ > \(containing-directory \"/foo/bar/bis.temp\"\)
63
+ \"/foo/bar/\"
64
+ > \(containing-directory \"/foo/bar/\"\)
65
+ \"/foo/\"
66
+ "
67
+ (make-pathname
68
+ :directory `(,@(butlast (pathname-directory pathspec)
69
+ (if (directory-pathname-p pathspec) 1 0)))
70
+ :name nil
71
+ :type nil
72
+ :defaults pathspec))
73
+
74
+ ;; FIXME -- abstract and merge with unique-directory
75
+ (defun unique-filename (pathname &optional (max-count 10000))
76
+ (let ((date-part (date-stamp)))
77
+ (loop repeat max-count
78
+ for index from 1
79
+ for name =
80
+ (merge-pathnames
81
+ (make-pathname
82
+ :name (format nil "~a-~a-~d"
83
+ (pathname-name pathname)
84
+ date-part index))
85
+ pathname) do
86
+ (unless (probe-file name)
87
+ (return-from unique-filename name)))
88
+ (error "Unable to find unique pathname for ~a; there are already ~:d similar files" pathname max-count)))
89
+
90
+ ;; FIXME -- abstract and merge with unique-filename
91
+ (defun unique-directory (pathname)
92
+ (setf pathname (merge-pathnames pathname))
93
+ (let* ((date-part (date-stamp))
94
+ (last-directory (first (last (pathname-directory pathname))))
95
+ (base-pathname (containing-pathname pathname))
96
+ (base-name (pathname-name last-directory))
97
+ (base-type (pathname-type last-directory)))
98
+ (or (loop repeat 10000
99
+ for index from 1
100
+ for name =
101
+ (merge-pathnames
102
+ (make-pathname
103
+ :name nil
104
+ :type nil
105
+ :directory `(:relative
106
+ ,(format nil "~@[~a-~]~a-~d~@[.~a~]"
107
+ base-name date-part index base-type)))
108
+ base-pathname) do
109
+ (unless (probe-file name)
110
+ (return name)))
111
+ (error "Unable to find unique pathname for ~a" pathname))))
112
+
113
+ (defun date-stamp (&key (datetime (get-universal-time)) (include-time? nil))
114
+ (multiple-value-bind
115
+ (second minute hour day month year day-of-the-week)
116
+ (decode-universal-time datetime)
117
+ (declare (ignore day-of-the-week))
118
+ (let ((date-part (format nil "~d-~2,'0d-~2,'0d" year month day))
119
+ (time-part (and include-time?
120
+ (list (format nil "-~2,'0d-~2,'0d-~2,'0d"
121
+ hour minute second)))))
122
+ (apply 'concatenate 'string date-part time-part))))
123
+
124
+
125
+ #+(or)
126
+ (date-stamp :include-time? t)
127
+
128
+ ;;; ---------------------------------------------------------------------------
129
+ ;;; shared stuff
130
+ ;;; ---------------------------------------------------------------------------
131
+
132
+ (defgeneric get-class (thing &key error?)
133
+ (:documentation "Returns the class of thing or nil if the class cannot be found. Thing can be a class, an object representing a class or a symbol naming a class. Get-class is like find-class only not as particular.")
134
+ (:method ((thing symbol) &key error?)
135
+ (find-class thing error?))
136
+ (:method ((thing standard-object) &key error?)
137
+ (declare (ignore error?))
138
+ (class-of thing))
139
+ (:method ((thing t) &key error?)
140
+ (declare (ignore error?))
141
+ (class-of thing))
142
+ (:method ((thing class) &key error?)
143
+ (declare (ignore error?))
144
+ thing))
145
+
146
+ (defun direct-subclasses (thing)
147
+ "Returns the immediate subclasses of thing. Thing can be a class, object or symbol naming a class."
148
+ (class-direct-subclasses (get-class thing)))
149
+
150
+ (defun map-subclasses (class fn &key proper?)
151
+ "Applies fn to each subclass of class. If proper? is true, then
152
+ the class itself is not included in the mapping. Proper? defaults to nil."
153
+ (let ((mapped (make-hash-table :test #'eq)))
154
+ (labels ((mapped-p (class)
155
+ (gethash class mapped))
156
+ (do-it (class root)
157
+ (unless (mapped-p class)
158
+ (setf (gethash class mapped) t)
159
+ (unless (and proper? root)
160
+ (funcall fn class))
161
+ (mapc (lambda (class)
162
+ (do-it class nil))
163
+ (direct-subclasses class)))))
164
+ (do-it (get-class class) t))))
165
+
166
+ (defun subclasses (class &key (proper? t))
167
+ "Returns all of the subclasses of the class including the class itself."
168
+ (let ((result nil))
169
+ (map-subclasses class (lambda (class)
170
+ (push class result))
171
+ :proper? proper?)
172
+ (nreverse result)))
173
+
174
+ (defun superclasses (thing &key (proper? t))
175
+ "Returns a list of superclasses of thing. Thing can be a class, object or symbol naming a class. The list of classes returned is 'proper'; it does not include the class itself."
176
+ (let ((result (class-precedence-list (get-class thing))))
177
+ (if proper? (rest result) result)))
178
+
179
+ #+(or)
180
+ ;;?? remove
181
+ (defun direct-superclasses (thing)
182
+ "Returns the immediate superclasses of thing. Thing can be a class, object or symbol naming a class."
183
+ (class-direct-superclasses (get-class thing)))
184
+
185
+ (declaim (inline length-1-list-p))
186
+ (defun length-1-list-p (x)
187
+ "Is x a list of length 1?"
188
+ (and (consp x) (null (cdr x))))
189
+
190
+ (defmacro defclass-property (property &optional (default nil default-supplied?))
191
+ "Create getter and setter methods for 'property' on symbol's property lists."
192
+ (let ((real-name (intern (format nil "~:@(~A~)" property) :keyword)))
193
+ `(progn
194
+ (defgeneric ,property (symbol))
195
+ (defgeneric (setf ,property) (value symbol))
196
+ (defmethod ,property ((class-name symbol))
197
+ (get class-name ,real-name ,@(when default-supplied? (list default))))
198
+ (defmethod (setf ,property) (value (class-name symbol))
199
+ (setf (get class-name ,real-name) value)))))
200
+
201
+ (defun parse-brief-slot (slot)
202
+ (let* ((slot-spec
203
+ (typecase slot
204
+ (symbol (list slot))
205
+ (list slot)
206
+ (t (error "Slot-spec must be a symbol or a list. `~s` is not."
207
+ slot)))))
208
+ (unless (null (cddr slot-spec))
209
+ (error "Slot-spec must be a symbol or a list of length one or two. `~s` has too many elements." slot))
210
+ `(,(first slot-spec) ,@(when (second slot-spec)
211
+ `(:initform ,(second slot-spec))))))
212
+
213
+ (defun convert-clauses-into-lists (clauses-and-options clauses-to-convert)
214
+ ;; This is useful (for me at least!) for writing macros
215
+ (let ((parsed-clauses nil))
216
+ (do* ((clauses clauses-and-options (rest clauses))
217
+ (clause (first clauses) (first clauses)))
218
+ ((null clauses))
219
+ (if (and (keywordp clause)
220
+ (or (null clauses-to-convert) (member clause clauses-to-convert))
221
+ (not (length-1-list-p clauses)))
222
+ (progn
223
+ (setf clauses (rest clauses))
224
+ (push (list clause (first clauses)) parsed-clauses))
225
+ (push clause parsed-clauses)))
226
+ (nreverse parsed-clauses)))
227
+
228
+ (defun remove-leading-quote (list)
229
+ "Removes the first quote from a list if one is there."
230
+ (if (and (consp list) (eql (first list) 'quote))
231
+ (first (rest list))
232
+ list))
233
+
234
+ (defun cleanup-parsed-parameter (parameter)
235
+ (if (length-1-list-p parameter)
236
+ (first parameter)
237
+ parameter))
238
+
239
+ (defun ensure-string (it)
240
+ (etypecase it
241
+ (string it)
242
+ (symbol (symbol-name it))))
@@ -0,0 +1,6 @@
1
+ (in-package #:common-lisp-user)
2
+
3
+ (defpackage #:metabang.lift.documentation
4
+ (:use #:common-lisp #:lift #:cl-markdown-user
5
+ #:metabang.docudown)
6
+ (:nicknames #:lift-documentation))
@@ -0,0 +1,17 @@
1
+ (in-package #:lift-documentation)
2
+
3
+ #+(or)
4
+ (defmethod additional-markdown-extensions-for-system
5
+ append ((system (eql (asdf:find-system 'lift-documentation))))
6
+ '(clcl))
7
+
8
+ (defmethod search-locations-for-system
9
+ append ((system (eql (asdf:find-system 'lift-documentation))))
10
+ (list (asdf:system-relative-pathname
11
+ 'lift-documentation "website/source/resources/")
12
+ (asdf:system-relative-pathname
13
+ 'lift-documentation "website/source/")
14
+ (asdf:system-relative-pathname
15
+ 'lift-documentation "../shared//")
16
+ ))
17
+
@@ -0,0 +1,289 @@
1
+ ;;;-*- Mode: Lisp; Package: LIFT -*-
2
+
3
+ #| simple-header
4
+
5
+ Copyright (c) 2001-2006 Gary Warren King (gwking@cs.umass.edu)
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a
8
+ copy of this software and associated documentation files (the "Software"),
9
+ to deal in the Software without restriction, including without limitation
10
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
11
+ and/or sell copies of the Software, and to permit persons to whom the
12
+ Software is furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23
+ DEALINGS IN THE SOFTWARE.
24
+
25
+ |#
26
+
27
+ (in-package #:lift)
28
+
29
+ ;;; ---------------------------------------------------------------------------
30
+ ;;; a simple example
31
+ ;;; ---------------------------------------------------------------------------
32
+
33
+ ;;; define an empty testsuite
34
+ (deftestsuite lift-examples-1 () ())
35
+ ;; => #<LIFT-EXAMPLES-1: no tests defined>
36
+
37
+ ;;; and add a test to it
38
+ (addtest (lift-examples-1)
39
+ (ensure-same (+ 1 1) 2))
40
+ ;; => #<Test passed>
41
+
42
+ ;;; add another test using ensure-error
43
+ (addtest (lift-examples-1)
44
+ (ensure-error (let ((x 0)) (/ x))))
45
+ ;; => #<Test passed>
46
+
47
+ ;;; add another, slightly more specific test
48
+ (addtest (lift-examples-1)
49
+ (ensure-condition division-by-zero (let ((x 0)) (/ x))))
50
+ ;; => #<Test passed>
51
+
52
+ ;;; run all the defined tests
53
+ (run-tests)
54
+ ;; => #<Results for LIFT-EXAMPLES-1 [3 Successful tests]>
55
+
56
+
57
+ ;;; ---------------------------------------------------------------------------
58
+ ;;; a simple example using deftestsuites :tests clause
59
+ ;;; ---------------------------------------------------------------------------
60
+
61
+ (deftestsuite lift-examples-2 ()
62
+ ()
63
+ (:tests
64
+ ((ensure-same (+ 1 1) 2))
65
+ ((ensure-error (let ((x 0)) (/ x))))
66
+ ((ensure-condition division-by-zero (let ((x 0)) (/ x))))))
67
+
68
+
69
+ ;;; ---------------------------------------------------------------------------
70
+ ;;; testing a simple function
71
+ ;;; ---------------------------------------------------------------------------
72
+
73
+ ;; !!! Incorrect definition
74
+ (defun dotted-pair-p (putative-pair)
75
+ (and (consp putative-pair)
76
+ (cdr putative-pair)))
77
+
78
+ ;;; ---------------------------------------------------------------------------
79
+
80
+ (deftestsuite test-dotted-pair-p ()
81
+ ()
82
+ (:tests
83
+ ((ensure (dotted-pair-p '(a . b))))
84
+ ((ensure (not (dotted-pair-p '(a b)))))
85
+ ((ensure (not (dotted-pair-p :a))))
86
+ ((ensure (not (dotted-pair-p '(a b . c)))))
87
+ ((ensure (not (dotted-pair-p nil))))))
88
+ ;; ==> #<Results for TEST-DOTTED-PAIR-P [5 Tests, 2 Failures]>
89
+
90
+ (describe (run-tests))
91
+ ;; ==> (prints)
92
+ Test Report for TEST-DOTTED-PAIR-P: 5 tests run, 2 Failures.
93
+
94
+ Failure: TEST-2
95
+ Condition: Ensure failed: (NOT (DOTTED-PAIR-P '(A B)))
96
+
97
+ Code : ((ENSURE (NOT (DOTTED-PAIR-P '(A B)))))
98
+
99
+ Failure: TEST-4
100
+ Condition: Ensure failed: (NOT (DOTTED-PAIR-P '(A B . C)))
101
+
102
+ Code : ((ENSURE (NOT (DOTTED-PAIR-P '(A B . C)))))
103
+
104
+ ;;; ---------------------------------------------------------------------------
105
+
106
+ ;; !!! Correct the defintion and run tests again
107
+ (defun dotted-pair-p (putative-pair)
108
+ (and (consp putative-pair)
109
+ (cdr putative-pair)
110
+ (not (consp (cdr putative-pair)))))
111
+
112
+ ;;; ---------------------------------------------------------------------------
113
+
114
+ (describe (run-tests))
115
+ ;; ==> Prints
116
+ Test Report for TEST-DOTTED-PAIR-P: 5 tests run, all passed!
117
+
118
+
119
+ ;;; ---------------------------------------------------------------------------
120
+ ;;; a test suite using slots
121
+ ;;; ---------------------------------------------------------------------------
122
+
123
+ (defun nearly-zero-p (number &optional (tolerance 0.0001))
124
+ (< (abs number) tolerance))
125
+
126
+ (progn
127
+ (deftestsuite test-nearly-zero-p ()
128
+ ((the-number-zero 0.0)
129
+ (not-nearly-zero 10000.0)
130
+ (close-to-zero 0.000000001)
131
+ (close-but-no-cigar 0.01)))
132
+
133
+ (addtest (test-nearly-zero-p)
134
+ (ensure (nearly-zero-p the-number-zero)))
135
+
136
+ (addtest (test-nearly-zero-p)
137
+ (ensure (not (nearly-zero-p not-nearly-zero))))
138
+
139
+ (addtest (test-nearly-zero-p)
140
+ (ensure (nearly-zero-p close-to-zero)))
141
+
142
+ (addtest (test-nearly-zero-p)
143
+ (ensure (not (nearly-zero-p close-but-no-cigar))))
144
+
145
+ (addtest (test-nearly-zero-p)
146
+ (ensure (nearly-zero-p close-but-no-cigar 0.1))))
147
+
148
+
149
+ (deftestsuite lift-examples () ())
150
+
151
+ (addtest (lift-examples)
152
+ (:documentation "This is the best test of all")
153
+ (let ((foo 1)
154
+ (faa 2)
155
+ (bar 3))
156
+ (setf foo (+ foo faa bar))
157
+ (setf foo 2)
158
+ (ensure (= (+ foo faa bar) (* foo faa bar)))))
159
+
160
+ (addtest (lift-examples)
161
+ (:documentation "This is the best test of all")
162
+ (let ((foo 1)
163
+ (faa 2)
164
+ (bar 3))
165
+ (setf foo (+ foo faa bar))
166
+ (setf foo 2)
167
+ (ensure (= (+ foo faa bar) (* foo far bar)))))
168
+
169
+ (addtest (lift-examples)
170
+ (ensure (= 2 3)))
171
+
172
+ (addtest (lift-examples)
173
+ (ensure (= 2 2)))
174
+
175
+ (addtest (lift-examples)
176
+ test-warning-2
177
+ (ensure-warning (+ 2 3)))
178
+
179
+ (addtest (lift-examples)
180
+ test-warning
181
+ (ensure-warning (warn "Help!")))
182
+
183
+ (addtest (lift-examples)
184
+ (:documentation "Testing ensure-same, should pass.")
185
+ (ensure-same (values "1" "2" "3") (values "1" "2" "3") :test #'string-equal))
186
+
187
+ (addtest (lift-examples)
188
+ (:documentation "Testing ensure-equal, should fail")
189
+ (ensure-same (values "1" "2" "3") (values "1" "2" "3") :test #'eql))
190
+
191
+ (addtest (lift-examples)
192
+ (ensure-error (warn "This test fails because a warning
193
+ is not an error.")))
194
+
195
+ (addTest (lift-examples)
196
+ (:documentation "This test will be logged as a
197
+ failure because no error will be generated.")
198
+ (ensure-warning (= 2 2)))
199
+
200
+ (addTest (lift-examples)
201
+ (:documentation "This test succeeds!")
202
+ (ensure-error (let ((x 0)) (print (/ 4 x)))))
203
+
204
+ (addTest (lift-examples)
205
+ (:documentation "This test should fail. Tests a bug where a warning would abort the test with no message.")
206
+ (warn "A test warning")
207
+ (ensure-same 1 2))
208
+
209
+ (run-tests :suite 'lift-examples)
210
+
211
+ ;;; ---------------------------------------------------------------------------
212
+ ;;;
213
+ ;;; ---------------------------------------------------------------------------
214
+
215
+ (deftestsuite more-lift-examples (lift-examples)
216
+ ((var-1 1))
217
+ (:documentation "More Examples")
218
+ (:test (test-initial-slot-value (ensure (= var-1 1))))
219
+ (:test ((ensure (= (1+ var-1) 2))))
220
+ (:test ((setf var-1 0) (ensure (= (1+ var-1) 1))))
221
+ (:test ((setf var-1 0) (ensure-warning (/ var-1))))
222
+ (:test ((setf var-1 0) (/ var-1) :documentation "Wow")))
223
+
224
+ (deftestsuite more-lift-examples (lift-examples)
225
+ ((var-1 1)
226
+ (var-2 2)))
227
+
228
+ (addtest (more-lift-examples)
229
+ test-initial-slot-value
230
+ (ensure (= var-1 1)))
231
+ (remove-test)
232
+ (addtest (more-lift-examples)
233
+ (ensure (= (1+ var-1) 2)))
234
+ (addtest (more-lift-examples)
235
+ (setf var-1 0)
236
+ (ensure (= (1+ var-1) 1)))
237
+ (addtest (more-lift-examples)
238
+ (setf var-1 0)
239
+ (ensure-warning (/ var-1)))
240
+
241
+
242
+ (addtest (more-lift-examples)
243
+ test-initial-slot-value
244
+ (ensure-same var-1 1))
245
+
246
+ (addtest (more-lift-examples)
247
+ test-initial-slot-value
248
+ (ensure-same "Hello" (concatenate 'string "he" "ll" "o")))
249
+
250
+ (addtest (more-lift-examples)
251
+ test-initial-slot-value
252
+ (ensure-same 1.23 1.23))
253
+
254
+ (addtest (more-lift-examples)
255
+ test-initial-slot-value
256
+ (ensure-same (floor 5/3) (values 1 2/3) :test #'=))
257
+
258
+
259
+ (addtest (more-lift-examples)
260
+ test-initial-slot-value
261
+ (ensure-same var-1 2))
262
+
263
+ (addtest (more-lift-examples)
264
+ test-initial-slot-value
265
+ (ensure-same var-1 1 :report "Var-1 is ~A, not 1." :args (list var-1)))
266
+
267
+ (addtest (more-lift-examples)
268
+ test-initial-slot-value
269
+ (ensure-same var-1 1 :report (lambda ()
270
+ (format nil "Var-1 is ~A, not 1." var-1))))
271
+
272
+ (addtest (more-lift-examples)
273
+ test-initial-slot-value
274
+ (ensure-same var-1 1 :report ("Var-1 is ~A, not 1." var-1)))
275
+
276
+
277
+ ;;; ---------------------------------------------------------------------------
278
+ ;;; compare with fiveam
279
+ ;;; ---------------------------------------------------------------------------
280
+
281
+ (deftestsuite my-suite ()
282
+ ()
283
+ (:documentation "My example suite")
284
+ (:tests
285
+ ((ensure-same 4 (+ 2 2)))
286
+ ((ensure-same 0 (+ -1 1)))
287
+ ((ensure-error (+ 'foo 4)))
288
+ ((ensure-same 0 (+ 1 1) :report "This should fail."))))
289
+
@@ -0,0 +1,32 @@
1
+ (in-package #:lift)
2
+
3
+ (deftestsuite integer-math () ())
4
+
5
+ (defrandom-instance an-integer nil (- (random 200) 100))
6
+
7
+ (addtest (integer-math)
8
+ commutivity
9
+ (with-random-cases 10 ((a an-integer) (b an-integer))
10
+ (format t "~&~a ~a" a b)
11
+ (ensure-same (+ a b) (+ b a) :test =)))
12
+
13
+ (deftestsuite small-positive-integer-math (integer-math)
14
+ ())
15
+
16
+ (addtest (small-positive-integer-math)
17
+ commutivity
18
+ (with-random-cases 10 ((a an-integer) (b an-integer))
19
+ (ensure-same (+ a b) (+ b a) :test =)))
20
+
21
+ (addtest (small-positive-integer-math)
22
+ closedness
23
+ (with-random-cases 10 ((a an-integer) (b an-integer))
24
+ (ensure (< (+ a b) 15))))
25
+
26
+ (defrandom-instance an-integer small-positive-integer-math
27
+ (1+ (random 10)))
28
+
29
+ (deftestsuite small-positive-integer-math (integer-math)
30
+ ()
31
+ (:random-instance an-integer (1+ (random 10))))
32
+
@@ -0,0 +1,28 @@
1
+ (in-package #:common-lisp-user)
2
+
3
+ (defpackage #:lift-documentation-system
4
+ (:use #:common-lisp #:asdf))
5
+ (in-package #:lift-documentation-system)
6
+
7
+ ;; just ignore for now... sigh.
8
+ (defsystem lift-documentation
9
+ :author "Gary King <gwking@metabang.com>"
10
+ :maintainer "Gary Warren King <gwking@metabang.com>"
11
+ :licence "MIT Style License"
12
+ :description "Documentation for LIFT"
13
+ :components (
14
+ #+(or)
15
+ (:module "setup"
16
+ :pathname "docs/"
17
+ :components ((:file "package")
18
+ (:file "setup"
19
+ :depends-on ("package"))))
20
+ #+(or)
21
+ (:module
22
+ "docs"
23
+ :depends-on ("setup")
24
+ :pathname "website/source/"
25
+ :components
26
+ ((:docudown-source "index.md")
27
+ (:docudown-source "user-guide.md"))))
28
+ :depends-on (:lift #+(or) :docudown))
@@ -0,0 +1,35 @@
1
+ (defpackage #:asdf-lift-test (:use #:asdf #:cl))
2
+ (in-package #:asdf-lift-test)
3
+
4
+ (defsystem lift-test
5
+ :author "Gary Warren King <gwking@metabang.com>"
6
+ :maintainer "Gary Warren King <gwking@metabang.com>"
7
+ :licence "MIT Style License; see file COPYING for details"
8
+ :description "Tests for LIsp Framework for Testing"
9
+ :components ((:module
10
+ "setup"
11
+ :pathname "test/"
12
+ :components ((:file "packages")
13
+ (:file "lift-test"
14
+ :depends-on ("packages"))))
15
+ (:module
16
+ "test"
17
+ :pathname "test/"
18
+ :depends-on ("setup")
19
+ :components ((:file "test-dynamic-variables")
20
+ (:file "equality-tests")
21
+ (:file "testsuite-expects")
22
+ (:file "finding-tests")
23
+ (:file "order-of-operations")
24
+ (:file "test-config-files")
25
+ (:file "test-maximum-problems")
26
+ #+(or)
27
+ (:file "test-prototypes"))))
28
+ :depends-on (:lift))
29
+
30
+ (defmethod operation-done-p
31
+ ((o test-op)
32
+ (c (eql (find-system 'lift-test))))
33
+ (values nil))
34
+
35
+