diff --git a/src/nako3.js b/src/nako3.js index 4d4ada88..34aaf7dc 100644 --- a/src/nako3.js +++ b/src/nako3.js @@ -80,7 +80,6 @@ class NakoCompiler { this.__v1 = this.__varslist[1] this.__vars = this.__varslist[2] this.gen.reset() - this.clearLog() } /** @@ -146,7 +145,8 @@ class NakoCompiler { } _run(code, isReset, isTest) { - if (isReset) {this.reset()} + this.reset() + if (isReset) {this.clearLog()} let js = this.compile(code, isTest) let __varslist = this.__varslist let __vars = this.__vars = this.__varslist[2] // eslint-disable-line diff --git a/test/func_test.js b/test/func_test.js index 5ab2df70..12da92a0 100644 --- a/test/func_test.js +++ b/test/func_test.js @@ -9,6 +9,10 @@ describe('func_test', () => { if (nako.debug) console.log('code=' + code) assert.equal(nako.runReset(code).log, res) } + const cmpWithoutReset = (code, res) => { + if (nako.debug) console.log('code=' + code) + assert.equal(nako.run(code).log, res) + } // --- test --- it('簡単な関数定義', () => { @@ -68,6 +72,17 @@ describe('func_test', () => { cmp('定数のN=30\n' + 'Nを表示。', '30') }) + it('ローカル定数2', () => { + const _res = '30' + let res = _res + + nako.clearLog() + for (let i = 0; i < 2; i++) { + cmpWithoutReset('定数のN=30\n' + + 'Nを表示。', res) + res += '\n' + _res + } + }) it('助詞の複数定義', () => { cmp('●加算処理(AにBを|AとBの)\n' + '(A+B)を戻す。\n' +