+5
.changeset/mighty-frogs-push.md
+5
.changeset/mighty-frogs-push.md
+8
src/__tests__/parser.test.ts
+8
src/__tests__/parser.test.ts
···
10
10
expect(doc).toMatchSnapshot();
11
11
});
12
12
13
+
it('parses unexpected EOF', () => {
14
+
expect(() => parse('#')).toThrow();
15
+
expect(() => parse(' ')).toThrow();
16
+
expect(() => parse('q($')).toThrow();
17
+
expect(() => parse('{x{')).toThrow();
18
+
expect(() => parse('#\n')).toThrow();
19
+
});
20
+
13
21
it('parses basic documents', () => {
14
22
expect(() => parse('{')).toThrow();
15
23
expect(() => parse('{}x ')).toThrow();
+2
-1
src/parser.ts
+2
-1
src/parser.ts
···
60
60
char === 65279 /*'\ufeff'*/;
61
61
char = input.charCodeAt(idx++) | 0
62
62
) {
63
-
if (char === 35 /*'#'*/) while ((char = input.charCodeAt(idx++)) !== 10 && char !== 13);
63
+
if (char === 35 /*'#'*/)
64
+
while ((char = input.charCodeAt(idx++) | 0) && char !== 10 && char !== 13);
64
65
}
65
66
idx--;
66
67
}