| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 class TokenizerTest { | 5 class TokenizerTest { |
| 6 static void main() { | 6 static void main() { |
| 7 print('start TokenizerTest'); | 7 print('start TokenizerTest'); |
| 8 testSourceLocations(); | 8 testSourceLocations(); |
| 9 testBasics(); | 9 testBasics(); |
| 10 testIncomplete(); | 10 testIncomplete(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 checkLocation(source, 9, 4, 1); | 36 checkLocation(source, 9, 4, 1); |
| 37 checkLocation(source, 10, 4, 2); | 37 checkLocation(source, 10, 4, 2); |
| 38 } | 38 } |
| 39 | 39 |
| 40 static void testBasics() { | 40 static void testBasics() { |
| 41 tokenTest('==> =>> +++', | 41 tokenTest('==> =>> +++', |
| 42 ['==', '>', '=>', '>', '++', '+']); | 42 ['==', '>', '=>', '>', '++', '+']); |
| 43 | 43 |
| 44 tokenTest('0123q 0123 0xabcg 3.14 1e10', | 44 tokenTest('0123q 0123 0xabcg 3.14 1e10', |
| 45 ['0123q', '0123', '0xabc', 'g', '3.14', '1e10'], | 45 ['0123q', '0123', '0xabc', 'g', '3.14', '1e10'], |
| 46 [TokenKind.ERROR, TokenKind.NUMBER, TokenKind.HEX_NUMBER, | 46 [TokenKind.ERROR, TokenKind.INTEGER, TokenKind.HEX_INTEGER, |
| 47 TokenKind.IDENTIFIER, TokenKind.NUMBER, TokenKind.NUMBER]); | 47 TokenKind.IDENTIFIER, TokenKind.DOUBLE, TokenKind.DOUBLE]); |
| 48 | 48 |
| 49 tokenTest('\$"foo" @"bar" \$abc @\'foo\' \$\'bar\'', | 49 tokenTest('\$"foo" @"bar" \$abc @\'foo\' \$\'bar\'', |
| 50 ['\$"foo"', '@"bar"', '\$abc', "@'foo'", "\$'bar'"], | 50 ['\$"foo"', '@"bar"', '\$abc', "@'foo'", "\$'bar'"], |
| 51 [TokenKind.STRING, TokenKind.STRING, TokenKind.IDENTIFIER, | 51 [TokenKind.STRING, TokenKind.STRING, TokenKind.IDENTIFIER, |
| 52 TokenKind.STRING, TokenKind.STRING]); | 52 TokenKind.STRING, TokenKind.STRING]); |
| 53 | 53 |
| 54 | 54 |
| 55 tokenTest('"hello \\"world" // comment', | 55 tokenTest('"hello \\"world" // comment', |
| 56 ['"hello \\"world"', '// comment'], | 56 ['"hello \\"world"', '// comment'], |
| 57 [TokenKind.STRING, TokenKind.COMMENT]); | 57 [TokenKind.STRING, TokenKind.COMMENT]); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 //print('${token.text} ${TokenKind.kindToString(token.kind)}'); | 108 //print('${token.text} ${TokenKind.kindToString(token.kind)}'); |
| 109 Expect.equals(expected[i], token.text); | 109 Expect.equals(expected[i], token.text); |
| 110 if (kinds != null) { | 110 if (kinds != null) { |
| 111 Expect.equals(kinds[i], token.kind); | 111 Expect.equals(kinds[i], token.kind); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 var t = tokenizer.next(); | 114 var t = tokenizer.next(); |
| 115 Expect.equals(TokenKind.END_OF_FILE, tokenizer.next().kind); | 115 Expect.equals(TokenKind.END_OF_FILE, tokenizer.next().kind); |
| 116 } | 116 } |
| 117 } | 117 } |
| OLD | NEW |