(setf a (- 1 a))
"a = 1 - a;")
+(test-ps-js assignment-6
+ (defun (setf color) (new-color el)
+ (setf (slot-value (slot-value el 'style) 'color) new-color))
+ "function __setf_color(newColor, el) {
+ el.style.color = newColor;
+};")
+
+(test-ps-js assignment-7
+ (setf (color some-div) (+ 23 "em"))
+ "var _js2 = someDiv;
+var _js1 = 23 + 'em';
+__setf_color(_js1, _js2);")
+
+(test-ps-js assignment-8
+ (defsetf left (el) (offset)
+ `(setf (slot-value (slot-value ,el 'style) 'left) ,offset))
+ "null")
+
+(test-ps-js assignment-9
+ (setf (left some-div) (+ 123 "px"))
+ "var _js2 = someDiv;
+var _js1 = 123 + 'px';
+_js2.style.left = _js1;")
+
+(test-ps-js assignment-10
+ (progn (defmacro left (el)
+ `(slot-value ,el 'offset-left))
+ (left some-div))
+ "someDiv.offsetLeft;")
+
(test-ps-js single-argument-statements-1
(return 1)
"return 1")
(test-ps-js variable-declaration-2
(if (= i 1)
- (progn (defvar blorg "hallo")
- (alert blorg))
- (progn (defvar blorg "blitzel")
- (alert blorg)))
+ (let* ((blorg "hallo"))
+ (alert blorg))
+ (let* ((blorg "blitzel"))
+ (alert blorg)))
"if (i == 1) {
var blorg = 'hallo';
alert(blorg);
(test-ps-js variable-declaration-3
(if (= i 1)
- (let ((blorg "hallo"))
+ (lexical-let* ((blorg "hallo"))
(alert blorg))
- (let ((blorg "blitzel"))
+ (lexical-let* ((blorg "blitzel"))
(alert blorg)))
"if (i == 1) {
- var blorg = 'hallo';
- alert(blorg);
+ (function () {
+ var newlexicalcontext1 = new Object;
+ newlexicalcontext1['blorg'] = 'hallo';
+ with (newlexicalcontext1) {
+ alert(blorg);
+ };
+ })();
} else {
- var blorg = 'blitzel';
- alert(blorg);
+ (function () {
+ var newlexicalcontext3 = new Object;
+ newlexicalcontext3['blorg'] = 'blitzel';
+ with (newlexicalcontext3) {
+ alert(blorg);
+ };
+ })();
}")
(test-ps-js iteration-constructs-1
}")
(test-ps-js the-html-generator-1
- (html ((:a :href "foobar") "blorg"))
+ (ps-html ((:a :href "foobar") "blorg"))
"'<a href=\"foobar\">blorg</a>'")
(test-ps-js the-html-generator-2
- (html ((:a :href (generate-a-link)) "blorg"))
+ (ps-html ((:a :href (generate-a-link)) "blorg"))
"'<a href=\"' + generateALink() + '\">blorg</a>'")
(test-ps-js the-html-generator-3
(document.write
- (html ((:a :href "#"
- :onclick (ps-inline (transport))) "link")))
- "document.write('<a href=\"#\" onclick=\"' + 'javascript:transport();' + '\">link</a>')")
+ (ps-html ((:a :href "#"
+ :onclick (lisp (ps-inline (transport)))) "link")))
+ "document.write('<a href=\"#\" onclick=\"' + 'javascript:transport()' + '\">link</a>')")
(test-ps-js the-html-generator-4
- (let ((disabled nil)
+ (let* ((disabled nil)
(authorized t))
(setf element.inner-h-t-m-l
- (html ((:textarea (or disabled (not authorized)) :disabled "disabled")
+ (ps-html ((:textarea (or disabled (not authorized)) :disabled "disabled")
"Edit me"))))
" var disabled = null;
var authorized = true;
+ (disabled || !authorized ? ' disabled=\"' + 'disabled' + '\"' : '')
+ '>Edit me</textarea>';")
-(test-ps-js the-html-generator-5
- (css-inline :color "red"
- :font-size "x-small")
- "'color:red;font-size:x-small'")
-
-(test-ps-js the-html-generator-6
- (defun make-color-div(color-name)
- (return (html ((:div :style (css-inline :color color-name))
- color-name " looks like this."))))
- "function makeColorDiv(colorName) {
- return '<div style=\"' + ('color:' + colorName) + '\">' + colorName
- + ' looks like this.</div>';
-}")
-