| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 import "package:compiler/src/platform_configuration.dart"; | 5 import "package:compiler/src/platform_configuration.dart"; |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 /// Runs the parser on [input] and compares it with [expectedResult] | 8 /// Runs the parser on [input] and compares it with [expectedResult] |
| 9 /// | 9 /// |
| 10 /// A '*' in [input] indicates that the parser will report an error at the | 10 /// A '*' in [input] indicates that the parser will report an error at the |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 Expect.equals(expectedOutput.length, result.length); | 28 Expect.equals(expectedOutput.length, result.length); |
| 29 expectedOutput.forEach((String name, Map<String, String> properties) { | 29 expectedOutput.forEach((String name, Map<String, String> properties) { |
| 30 Expect.isTrue(expectedOutput.containsKey(name), "Missing section $name"); | 30 Expect.isTrue(expectedOutput.containsKey(name), "Missing section $name"); |
| 31 Expect.mapEquals(expectedOutput[name], properties); | 31 Expect.mapEquals(expectedOutput[name], properties); |
| 32 }); | 32 }); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 main() { | 36 main() { |
| 37 // Empty file. | 37 // Empty file. |
| 38 test( | 38 test(""" |
| 39 """ | |
| 40 # Nothing here | 39 # Nothing here |
| 41 """, | 40 """, {}); |
| 42 {}); | |
| 43 | 41 |
| 44 // Text outside section. | 42 // Text outside section. |
| 45 test(""" | 43 test(""" |
| 46 *aaa | 44 *aaa |
| 47 """); | 45 """); |
| 48 | 46 |
| 49 // Malformed header. | 47 // Malformed header. |
| 50 test(""" | 48 test(""" |
| 51 *[AABC | 49 *[AABC |
| 52 name:value | 50 name:value |
| (...skipping 22 matching lines...) Expand all Loading... |
| 75 """); | 73 """); |
| 76 | 74 |
| 77 // Empty property name. | 75 // Empty property name. |
| 78 test(""" | 76 test(""" |
| 79 [AA] | 77 [AA] |
| 80 *:value | 78 *:value |
| 81 name:value | 79 name:value |
| 82 """); | 80 """); |
| 83 | 81 |
| 84 // Ok. | 82 // Ok. |
| 85 test( | 83 test(""" |
| 86 """ | |
| 87 [AA] | 84 [AA] |
| 88 name:value | 85 name:value |
| 89 [BB] | 86 [BB] |
| 90 name:value | 87 name:value |
| 91 name2:value2 | 88 name2:value2 |
| 92 """, | 89 """, { |
| 93 { | 90 "AA": {"name": "value"}, |
| 94 "AA": {"name": "value"}, | 91 "BB": {"name": "value", "name2": "value2"} |
| 95 "BB": {"name": "value", "name2": "value2"} | 92 }); |
| 96 }); | |
| 97 | 93 |
| 98 // Ok, file not ending in newline. | 94 // Ok, file not ending in newline. |
| 99 test( | 95 test(""" |
| 100 """ | |
| 101 [AA] | 96 [AA] |
| 102 name:value""", | 97 name:value""", { |
| 103 { | 98 "A": {"name": "value"} |
| 104 "A": {"name": "value"} | 99 }); |
| 105 }); | |
| 106 | 100 |
| 107 // Ok, whitespace is trimmed away. | 101 // Ok, whitespace is trimmed away. |
| 108 test( | 102 test(""" |
| 109 """ | |
| 110 [ AA ] | 103 [ AA ] |
| 111 name\t: value """, | 104 name\t: value """, { |
| 112 { | 105 "A": {"name": "value"} |
| 113 "A": {"name": "value"} | 106 }); |
| 114 }); | |
| 115 | 107 |
| 116 // Duplicate property name. | 108 // Duplicate property name. |
| 117 test(""" | 109 test(""" |
| 118 [AA] | 110 [AA] |
| 119 a:b | 111 a:b |
| 120 b:c | 112 b:c |
| 121 *a:c | 113 *a:c |
| 122 """); | 114 """); |
| 123 | 115 |
| 124 // No ':' on property line. | 116 // No ':' on property line. |
| 125 test(""" | 117 test(""" |
| 126 [AA] | 118 [AA] |
| 127 *name1 | 119 *name1 |
| 128 name2:value | 120 name2:value |
| 129 """); | 121 """); |
| 130 } | 122 } |
| OLD | NEW |