diff --git a/src/parser.js b/src/parser.js
index d0dee45ee..6757e9bf0 100644
--- a/src/parser.js
+++ b/src/parser.js
@@ -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;
diff --git a/test/unit/parser_spec.js b/test/unit/parser_spec.js
new file mode 100644
index 000000000..69a6be954
--- /dev/null
+++ b/test/unit/parser_spec.js
@@ -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);
+ });
+ });
+});
+
diff --git a/test/unit/unit_test.html b/test/unit/unit_test.html
index 0291f1a0f..3f54c06ad 100644
--- a/test/unit/unit_test.html
+++ b/test/unit/unit_test.html
@@ -41,6 +41,7 @@
+