Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
parenscript
parenscript
Commits
cf4cab20
Verified
Commit
cf4cab20
authored
Oct 24, 2018
by
Vladimir Sedach
Browse files
Bind DOLIST/DOTIMES var to nil before evaluating result form
parent
5262b5fd
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/macros.lisp
View file @
cf4cab20
...
...
@@ -395,7 +395,8 @@ lambda-list::=
(
defpsmacro
dotimes
((
var
count
&optional
(
result
nil
result?
))
&rest
body
)
`
(
do*
((
,
var
0
(
1+
,
var
)))
((
>=
,
var
,
count
)
,@
(
when
result?
(
list
result
)))
((
>=
,
var
,
count
)
,@
(
when
result?
`
((
let
((
,
var
nil
))
,
result
))))
,@
body
))
(
defpsmacro
dolist
((
var
array
&optional
(
result
nil
result?
))
&body
body
)
...
...
@@ -409,7 +410,7 @@ lambda-list::=
(
list
(
list
arrvar
array
)))
(
,
idx
0
(
1+
,
idx
)))
((
>=
,
idx
(
getprop
,
arrvar
'length
))
,@
(
when
result?
(
list
result
)))
,@
(
when
result?
`
((
let
((
,
var
nil
))
,
result
)))
)
(
setq
,
var
(
aref
,
arrvar
,
idx
))
,@
body
)))
...
...
tests/eval-tests.lisp
View file @
cf4cab20
...
...
@@ -61,7 +61,7 @@
(
test-js-eval
empty-array
(
array
)
'
())
#
(
))
(
test-js-eval
funargs-let1
((
lambda
(
x
)
...
...
@@ -910,3 +910,13 @@
3
)
(
setf
x
(
+
2
(
side-effect
)
x
5
)))
14
)
(
test-js-eval
dolist-result-bind-nil
(
dolist
(
i
'
(
1
2
3
)
(
list
i
9
))
(
list
i
))
'
(
nil
9
))
(
test-js-eval
dotimes-result-bind-nil
(
dotimes
(
i
'
(
1
2
3
)
(
list
9
i
))
(
list
i
))
'
(
9
nil
))
tests/output-tests.lisp
View file @
cf4cab20
...
...
@@ -554,6 +554,7 @@ return alert('Summation to 10 is ' + (function () {
for (var i = 0; i < 10; i += 1) {
res += i + 1;
};
var i = null;
return res;
})());
})();"
)
...
...
@@ -584,6 +585,7 @@ return alert('Sum of ' + l + ' is: ' + (function () {
c = l[_js_idx1];
s += c;
};
var c = null;
return s;
})());
})();"
)
...
...
tests/test.lisp
View file @
cf4cab20
...
...
@@ -48,12 +48,13 @@
(
ps-doc*
',parenscript
)))))))
(
defun
js-repr
(
x
)
(
if
(
listp
x
)
(
cl-js:js-array
(
make-array
(
length
x
)
:initial-contents
(
mapcar
#'
js-repr
x
)
:adjustable
t
))
x
))
(
cond
((
or
(
consp
x
)
(
simple-vector-p
x
))
(
cl-js:js-array
(
make-array
(
length
x
)
:initial-contents
(
map
'vector
#'
js-repr
x
)
:adjustable
t
)))
((
null
x
)
:null
)
(
t
x
)))
(
defmacro
%test-js-eval
(
testname
parenscript
test-statement
)
`
(
fiveam:test
,
testname
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment