Merge pull request #2303 from yurydelendik/issue-1471

Fixes getNumber at the end of stream
This commit is contained in:
Brendan Dahl 2012-10-24 10:01:10 -07:00
commit 89ac3fd162
3 changed files with 19 additions and 2 deletions

View File

@ -333,8 +333,7 @@ var Lexer = (function LexerClosure() {
var floating = false;
var str = ch;
var stream = this.stream;
for (;;) {
ch = stream.lookChar();
while ((ch = stream.lookChar())) {
if (ch == '.' && !floating) {
str += ch;
floating = true;

17
test/unit/parser_spec.js Normal file
View File

@ -0,0 +1,17 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
'use strict';
describe('parser', function() {
describe('Lexer', function() {
it('should stop parsing numbers at the end of stream', function() {
var input = new StringStream('1.234');
var lexer = new Lexer(input);
var result = lexer.getNumber('1');
expect(result).toEqual(11.234);
});
});
});

View File

@ -41,6 +41,7 @@
<script type="text/javascript" src="crypto_spec.js"></script>
<script type="text/javascript" src="evaluator_spec.js"></script>
<script type="text/javascript" src="stream_spec.js"></script>
<script type="text/javascript" src="parser_spec.js"></script>
<script type="text/javascript" src="api_spec.js"></script>
<script type="text/javascript" src="metadata_spec.js"></script>
<script type="text/javascript" src="util_spec.js"></script>