Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: Interpreter#evaluate should reset call_stack
fix #122
  • Loading branch information
yhara committed Nov 17, 2018
1 parent a8dcc24 commit 405e1a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/system/interpreter.js
Expand Up @@ -402,6 +402,7 @@ BiwaScheme.Interpreter = BiwaScheme.Class.create({

// Compile and evaluate Scheme program
evaluate: function(str, after_evaluate){
this.call_stack = [];
this.parser = new BiwaScheme.Parser(str);
this.compiler = new BiwaScheme.Compiler();
if(after_evaluate)
Expand Down
7 changes: 7 additions & 0 deletions test/unit.js
Expand Up @@ -141,6 +141,13 @@ describe('Interpreter', {
expect( BiwaScheme.inspect(intp.call_stack) ).should_be('[]');
},

'stack trace (reset on errors)': function(){
var intp = new BiwaScheme.Interpreter();
intp.evaluate("((lambda () a))");
intp.evaluate("((lambda () a))");
expect( BiwaScheme.inspect(intp.call_stack) ).should_be('["(anon)"]');
},

'define_scmfunc': function() {
BiwaScheme.define_scmfunc('scmfunc-test', 1, 1,
"(lambda (n) \
Expand Down

0 comments on commit 405e1a1

Please sign in to comment.