Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library engine.parser_test; | 5 library engine.parser_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
| 9 import 'package:analyzer/src/generated/error.dart'; | 9 import 'package:analyzer/src/generated/error.dart'; |
| 10 import 'package:analyzer/src/generated/incremental_scanner.dart'; | 10 import 'package:analyzer/src/generated/incremental_scanner.dart'; |
| (...skipping 8816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8827 parse4("parseStringLiteral", "'a \${b} c \$this d'"); | 8827 parse4("parseStringLiteral", "'a \${b} c \$this d'"); |
| 8828 NodeList<InterpolationElement> elements = literal.elements; | 8828 NodeList<InterpolationElement> elements = literal.elements; |
| 8829 expect(elements, hasLength(5)); | 8829 expect(elements, hasLength(5)); |
| 8830 expect(elements[0] is InterpolationString, isTrue); | 8830 expect(elements[0] is InterpolationString, isTrue); |
| 8831 expect(elements[1] is InterpolationExpression, isTrue); | 8831 expect(elements[1] is InterpolationExpression, isTrue); |
| 8832 expect(elements[2] is InterpolationString, isTrue); | 8832 expect(elements[2] is InterpolationString, isTrue); |
| 8833 expect(elements[3] is InterpolationExpression, isTrue); | 8833 expect(elements[3] is InterpolationExpression, isTrue); |
| 8834 expect(elements[4] is InterpolationString, isTrue); | 8834 expect(elements[4] is InterpolationString, isTrue); |
| 8835 } | 8835 } |
| 8836 | 8836 |
| 8837 void test_parseStringLiteral_multiline_encodedSpace() { | |
| 8838 SimpleStringLiteral literal = | |
| 8839 parse4("parseStringLiteral", "'''\\x20\na'''"); | |
| 8840 expect(literal.literal, isNotNull); | |
| 8841 expect(literal.value, " \na"); | |
| 8842 } | |
| 8843 | |
| 8844 void test_parseStringLiteral_multiline_escapedBackslash() { | |
| 8845 SimpleStringLiteral literal = parse4("parseStringLiteral", "'''\\\\\na'''"); | |
| 8846 expect(literal.literal, isNotNull); | |
| 8847 expect(literal.value, "\\\na"); | |
| 8848 } | |
| 8849 | |
| 8850 void test_parseStringLiteral_multiline_escapedBackslash_raw() { | |
| 8851 SimpleStringLiteral literal = | |
| 8852 parse4("parseStringLiteral", "r'''\\\\\na'''"); | |
| 8853 expect(literal.literal, isNotNull); | |
| 8854 expect(literal.value, "\\\\\na"); | |
| 8855 } | |
| 8856 | |
| 8857 void test_parseStringLiteral_multiline_escapedEolMarker() { | |
| 8858 SimpleStringLiteral literal = parse4("parseStringLiteral", "'''\\\na'''"); | |
| 8859 expect(literal.literal, isNotNull); | |
| 8860 expect(literal.value, "a"); | |
| 8861 } | |
| 8862 | |
| 8863 void test_parseStringLiteral_multiline_escapedEolMarker_raw() { | |
| 8864 SimpleStringLiteral literal = parse4("parseStringLiteral", "r'''\\\na'''"); | |
| 8865 expect(literal.literal, isNotNull); | |
| 8866 expect(literal.value, "a"); | |
| 8867 } | |
| 8868 | |
| 8869 void test_parseStringLiteral_multiline_escapedSpaceAndEolMarker() { | |
| 8870 SimpleStringLiteral literal = | |
| 8871 parse4("parseStringLiteral", "'''\\ \\\na'''"); | |
| 8872 expect(literal.literal, isNotNull); | |
| 8873 expect(literal.value, "a"); | |
| 8874 } | |
| 8875 | |
| 8876 void test_parseStringLiteral_multiline_escapedSpaceAndEolMarker_raw() { | |
| 8877 SimpleStringLiteral literal = | |
| 8878 parse4("parseStringLiteral", "'''\\ \\\na'''"); | |
|
Paul Berry
2015/03/26 21:40:52
Missing the "r" character on this line.
Brian Wilkerson
2015/03/26 21:45:21
Good catch! Done.
| |
| 8879 expect(literal.literal, isNotNull); | |
| 8880 expect(literal.value, "a"); | |
| 8881 } | |
| 8882 | |
| 8883 void test_parseStringLiteral_multiline_escapedTab() { | |
| 8884 SimpleStringLiteral literal = parse4("parseStringLiteral", "'''\\t\na'''"); | |
| 8885 expect(literal.literal, isNotNull); | |
| 8886 expect(literal.value, "\t\na"); | |
| 8887 } | |
| 8888 | |
| 8889 void test_parseStringLiteral_multiline_escapedTab_raw() { | |
| 8890 SimpleStringLiteral literal = parse4("parseStringLiteral", "r'''\\t\na'''"); | |
| 8891 expect(literal.literal, isNotNull); | |
| 8892 expect(literal.value, "\\t\na"); | |
| 8893 } | |
| 8894 | |
| 8895 void test_parseStringLiteral_multiline_twoSpaces() { | |
| 8896 SimpleStringLiteral literal = parse4("parseStringLiteral", "''' \na'''"); | |
| 8897 expect(literal.literal, isNotNull); | |
| 8898 expect(literal.value, "a"); | |
| 8899 } | |
| 8900 | |
| 8901 void test_parseStringLiteral_multiline_twoSpaces_raw() { | |
| 8902 SimpleStringLiteral literal = parse4("parseStringLiteral", "r''' \na'''"); | |
| 8903 expect(literal.literal, isNotNull); | |
| 8904 expect(literal.value, "a"); | |
| 8905 } | |
| 8906 | |
| 8907 void test_parseStringLiteral_multiline_untrimmed() { | |
| 8908 SimpleStringLiteral literal = parse4("parseStringLiteral", "''' a\nb'''"); | |
| 8909 expect(literal.literal, isNotNull); | |
| 8910 expect(literal.value, " a\nb"); | |
| 8911 } | |
| 8912 | |
| 8837 void test_parseStringLiteral_single() { | 8913 void test_parseStringLiteral_single() { |
| 8838 SimpleStringLiteral literal = parse4("parseStringLiteral", "'a'"); | 8914 SimpleStringLiteral literal = parse4("parseStringLiteral", "'a'"); |
| 8839 expect(literal.literal, isNotNull); | 8915 expect(literal.literal, isNotNull); |
| 8840 expect(literal.value, "a"); | 8916 expect(literal.value, "a"); |
| 8841 } | 8917 } |
| 8842 | 8918 |
| 8843 void test_parseSuperConstructorInvocation_named() { | 8919 void test_parseSuperConstructorInvocation_named() { |
| 8844 SuperConstructorInvocation invocation = | 8920 SuperConstructorInvocation invocation = |
| 8845 parse4("parseSuperConstructorInvocation", "super.a()"); | 8921 parse4("parseSuperConstructorInvocation", "super.a()"); |
| 8846 expect(invocation.argumentList, isNotNull); | 8922 expect(invocation.argumentList, isNotNull); |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9825 new Scanner(null, new CharSequenceReader(source), listener); | 9901 new Scanner(null, new CharSequenceReader(source), listener); |
| 9826 Token tokenStream = scanner.tokenize(); | 9902 Token tokenStream = scanner.tokenize(); |
| 9827 // | 9903 // |
| 9828 // Parse the source. | 9904 // Parse the source. |
| 9829 // | 9905 // |
| 9830 Parser parser = new Parser(null, listener); | 9906 Parser parser = new Parser(null, listener); |
| 9831 return invokeParserMethodImpl( | 9907 return invokeParserMethodImpl( |
| 9832 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 9908 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
| 9833 } | 9909 } |
| 9834 } | 9910 } |
| OLD | NEW |