diff options
| author | Misko Hevery | 2010-12-07 11:42:34 -0800 | 
|---|---|---|
| committer | Misko Hevery | 2010-12-08 14:39:22 -0800 | 
| commit | 23fc73081feb640164615930b36ef185c23a3526 (patch) | |
| tree | 3354648159e348e97ba4b49c005d7c9e64a343bd /test/ParserSpec.js | |
| parent | e5e69d9b90850eb653883f52c76e28dd870ee067 (diff) | |
| download | angular.js-23fc73081feb640164615930b36ef185c23a3526.tar.bz2 | |
Refactor lexer to use regular expressions
Diffstat (limited to 'test/ParserSpec.js')
| -rw-r--r-- | test/ParserSpec.js | 22 | 
1 files changed, 9 insertions, 13 deletions
| diff --git a/test/ParserSpec.js b/test/ParserSpec.js index c237aa40..71208783 100644 --- a/test/ParserSpec.js +++ b/test/ParserSpec.js @@ -82,9 +82,15 @@ describe('parser', function() {        expect(tokens.length).toEqual(1);        expect(tokens[0].string).toEqual('\u00a0');      }); +     +    it('should error when non terminated string', function(){ +      expect(function(){ +        lex('ignore "text'); +      }).toThrow(new Error('Lexer Error: Unterminated string at column 7 in expression [ignore "text].')); +    });      it('should ignore whitespace', function() { -      var tokens = lex("a \t \n \r b"); +      var tokens = lex("a \t \n \r \u00A0 b");        expect(tokens[0].text).toEqual('a');        expect(tokens[1].text).toEqual('b');      }); @@ -130,16 +136,6 @@ describe('parser', function() {        expect(tokens[0].text).toEqual(0.5E+10);      }); -    it('should throws exception for invalid exponent', function() { -      expect(function() { -        lex("0.5E-"); -      }).toThrow(new Error('Lexer Error: Invalid exponent at column 4 in expression [0.5E-].')); -       -      expect(function() { -        lex("0.5E-A"); -      }).toThrow(new Error('Lexer Error: Invalid exponent at column 4 in expression [0.5E-A].')); -    }); -      it('should tokenize number starting with a dot', function() {        var tokens = lex(".5");        expect(tokens[0].text).toEqual(0.5); @@ -147,8 +143,8 @@ describe('parser', function() {      it('should throw error on invalid unicode', function() {        expect(function() { -        lex("'\\u1''bla'"); -      }).toThrow(new Error("Lexer Error: Invalid unicode escape [\\u1''b] at column 2 in expression ['\\u1''bla'].")); +        lex("'\\u1xbla'"); +      }).toThrow(new Error("Lexer Error: Invalid unicode escape [\\u1xbl] at columns 0-9 ['\\u1xbla'] in expression ['\\u1xbla']."));      });    }); | 
