From e67c3c69245525c0c46b8b4b438f066fe8ae17fe Mon Sep 17 00:00:00 2001 From: wyozi Date: Fri, 9 Oct 2020 15:15:52 +0300 Subject: [PATCH] Make end brace peek stricter and fix the test --- src/parser/tokenizer.ts | 3 ++- test/unit/parser/tokenizer.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/parser/tokenizer.ts b/src/parser/tokenizer.ts index a5de274aa..16e253788 100644 --- a/src/parser/tokenizer.ts +++ b/src/parser/tokenizer.ts @@ -211,7 +211,8 @@ export class Tokenizer { this.p++ const prop = this.readQuoted() if (!prop) return - this.readTo(']') + if (this.peek() !== ']') return + this.p++ return new PropertyAccessToken(prop, [], this.p) } diff --git a/test/unit/parser/tokenizer.ts b/test/unit/parser/tokenizer.ts index 7d734777b..7f5810651 100644 --- a/test/unit/parser/tokenizer.ts +++ b/test/unit/parser/tokenizer.ts @@ -40,8 +40,8 @@ describe('Tokenize', function () { expect((value as PropertyAccessToken).variable.getText()).to.equal('"a prop"') }) it('should throw for incomplete quoted property access', () => { - const tokenizer = new Tokenizer('["a prop"]') - expect(() => tokenizer.readValue()).to.throw() + const tokenizer = new Tokenizer('["a prop"') + expect(() => tokenizer.readValueOrThrow()).to.throw() }) it('should read hash', () => { const hash1 = new Tokenizer('foo: 3').readHash()