651c6cb5e5ca4c372894777340a154d9f99341b7
3 ;; Testcases for parenscript
5 (defun trim-whitespace(str)
6 (string-trim '(#\Space
#\Tab
#\Newline
) str
))
8 (defun same-space-between-statements(code)
9 (cl-ppcre:regex-replace-all
"\\s*;\\s*" code
(concatenate 'string
(list #\
; #\Newline))))
11 (defun no-indentation(code)
12 (cl-ppcre:regex-replace-all
(cl-ppcre:create-scanner
"^\\s*" :multi-line-mode t
) code
""))
14 (defun no-trailing-spaces(code)
15 (cl-ppcre:regex-replace-all
(cl-ppcre:create-scanner
"\\s*$" :multi-line-mode t
) code
""))
17 (defun normalize-js-code(str)
18 (trim-whitespace (no-indentation (no-trailing-spaces (same-space-between-statements str
)))))
20 (defmacro test-ps-js
(testname parenscript javascript
)
22 (setf js
::*var-counter
* 0)
23 ;; is-macro expands its argument again when reporting failures, so
24 ;; the reported temporary js-variables get wrong if we don't evalute first.
25 (let ((generated-code (js-to-string ',parenscript
))
26 (js-code ,javascript
))
27 (is (string= (normalize-js-code generated-code
)
28 (normalize-js-code js-code
))))))
31 (format t
"Running reference tests:~&")
33 (format t
"Running other tests:~&")
36 ;;---------------------------------------------------------------------------
40 ;; A problem with long nested operator, when the statement spanned several rows
41 ;; the rows would not be joined together correctly.
42 (test-ps-js bug-dwim-join
43 (alert (html ((:div
:id
777
44 :style
(css-inline :border
"1pxsssssssssss"
49 ('<div id=\"777\" style=\"'
50 + ('border:1pxsssssssssss;font-size:x-small;height:' + 2 * 200 + ';width:'
52 + '\"></div>')") ;";This line should start with a plus character.
55 (test-ps-js simple-slot-value
56 (let ((foo (create :a
1)))
57 (alert (slot-value foo
'a
)))
63 (test-ps-js buggy-slot-value
64 (let ((foo (create :a
1))
66 (alert (slot-value foo slot-name
)))
71 }"); Last line was alert(foo.slotName) before bug-fix.
73 (test-ps-js buggy-slot-value-two
74 (slot-value foo
(get-slot-name))