mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-07 15:28:49 +00:00
Fixed bug with mutable closures in interpret (not really --- up to closure recursion)
This commit is contained in:
parent
1d28f4af6b
commit
dad4c35a80
5 changed files with 31 additions and 7 deletions
|
|
@ -8,9 +8,9 @@ check: $(TESTS)
|
|||
|
||||
$(TESTS): %: %.expr
|
||||
@echo $@
|
||||
$(RC) $< && cat $@.input | ./$@ 2> /dev/null > $@.log && diff $@.log orig/$@.log
|
||||
$(RC) $< && cat $@.input | ./$@ > $@.log && diff $@.log orig/$@.log
|
||||
cat $@.input | $(RC) -i $< > $@.log && diff $@.log orig/$@.log
|
||||
cat $@.input | $(RC) -s $< 2> /dev/null > $@.log && diff $@.log orig/$@.log
|
||||
cat $@.input | $(RC) -s $< > $@.log && diff $@.log orig/$@.log
|
||||
|
||||
clean:
|
||||
$(RM) test*.log *.s *~ $(TESTS)
|
||||
|
|
|
|||
3
regression/orig/test068.log
Normal file
3
regression/orig/test068.log
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
> 1
|
||||
800
|
||||
800
|
||||
19
regression/test068.expr
Normal file
19
regression/test068.expr
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
fun lazy (f) {
|
||||
local flag = 0, value = 0;
|
||||
|
||||
return fun () {
|
||||
if flag
|
||||
then return value
|
||||
else
|
||||
value := f ();
|
||||
flag := 1;
|
||||
return value
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
local l = lazy (fun () {write (1); return 800});
|
||||
local x = read ();
|
||||
|
||||
write (l ());
|
||||
write (l ())
|
||||
1
regression/test068.input
Normal file
1
regression/test068.input
Normal file
|
|
@ -0,0 +1 @@
|
|||
5
|
||||
Loading…
Add table
Add a link
Reference in a new issue