diff options
| author | Shyam Seshadri | 2010-10-08 17:11:45 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-10-08 20:41:19 -0700 |
| commit | 8490bb921bd03239f5856cd44b7e21ef6db23eca (patch) | |
| tree | 2bc58b6247ab1f68796ccb0570365e3ae8c48e72 /test/ParserTest.js | |
| parent | e3ea980c819f62b8c2021f813e3534e4e5731d7d (diff) | |
| download | angular.js-8490bb921bd03239f5856cd44b7e21ef6db23eca.tar.bz2 | |
Fix bug with Lexer not recognizing exponential values and values starting with dots
Diffstat (limited to 'test/ParserTest.js')
| -rw-r--r-- | test/ParserTest.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ParserTest.js b/test/ParserTest.js index 6a70bce8..916beb26 100644 --- a/test/ParserTest.js +++ b/test/ParserTest.js @@ -141,6 +141,38 @@ LexerTest.prototype.testNumber = function(){ expect(tokens[0].text).toEqual(0.5); }; +LexerTest.prototype.testNegativeNumber = function(){ + var value = createScope().$eval("-0.5"); + expect(value).toEqual(-0.5); + + value = createScope().$eval("{a:-0.5}"); + expect(value).toEqual({a:-0.5}); +}; + +LexerTest.prototype.testNumberExponent = function(){ + var tokens = lex("0.5E-10"); + expect(tokens[0].text).toEqual(0.5E-10); + expect(createScope().$eval("0.5E-10")).toEqual(0.5E-10); + + tokens = lex("0.5E+10"); + expect(tokens[0].text).toEqual(0.5E+10); +}; + +LexerTest.prototype.testNumberExponentInvalid = function(){ + assertThrows('Lexer found invalid exponential value "0.5E-"', function(){ + lex("0.5E-"); + }); + assertThrows('Lexer found invalid exponential value "0.5E-A"', function(){ + lex("0.5E-A"); + }); +}; + +LexerTest.prototype.testNumberStartingWithDot = function(){ + var tokens = lex(".5"); + expect(tokens[0].text).toEqual(0.5); +}; + + ParserTest = TestCase('ParserTest'); ParserTest.prototype.testExpressions = function(){ |
