| 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 library package_config.parse_test; | 5 library package_config.parse_test; |
| 6 | 6 |
| 7 import "package:package_config/packages.dart"; | 7 import "package:package_config/packages.dart"; |
| 8 import "package:package_config/packages_file.dart" show parse; | 8 import "package:package_config/packages_file.dart" show parse; |
| 9 import "package:package_config/src/packages_impl.dart"; | 9 import "package:package_config/src/packages_impl.dart"; |
| 10 import "package:test/test.dart"; | 10 import "package:test/test.dart"; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 }); | 95 }); |
| 96 | 96 |
| 97 test("no invalid chars accepted", () { | 97 test("no invalid chars accepted", () { |
| 98 var map = {}; | 98 var map = {}; |
| 99 for (int i = 0; i < allValidChars.length; i++) { | 99 for (int i = 0; i < allValidChars.length; i++) { |
| 100 map[allValidChars.codeUnitAt(i)] = true; | 100 map[allValidChars.codeUnitAt(i)] = true; |
| 101 } | 101 } |
| 102 for (int i = 0; i <= 255; i++) { | 102 for (int i = 0; i <= 255; i++) { |
| 103 if (map[i] == true) continue; | 103 if (map[i] == true) continue; |
| 104 var char = new String.fromCharCode(i); | 104 var char = new String.fromCharCode(i); |
| 105 expect(() => doParse("x${char}x:x", null), throws); | 105 expect(() => doParse("x${char}x:x", null), |
| 106 anyOf(throwsNoSuchMethodError, throwsFormatException)); |
| 106 } | 107 } |
| 107 }); | 108 }); |
| 108 | 109 |
| 109 test("no escapes", () { | 110 test("no escapes", () { |
| 110 expect(() => doParse("x%41x:x", base), throws); | 111 expect(() => doParse("x%41x:x", base), throwsFormatException); |
| 111 }); | 112 }); |
| 112 | 113 |
| 113 test("same name twice", () { | 114 test("same name twice", () { |
| 114 expect(() => doParse(singleRelativeSample * 2, base), throws); | 115 expect( |
| 116 () => doParse(singleRelativeSample * 2, base), throwsFormatException); |
| 115 }); | 117 }); |
| 116 | 118 |
| 117 for (String invalidSample in invalid) { | 119 for (String invalidSample in invalid) { |
| 118 test("invalid '$invalidSample'", () { | 120 test("invalid '$invalidSample'", () { |
| 119 var result; | 121 var result; |
| 120 try { | 122 try { |
| 121 result = doParse(invalidSample, base); | 123 result = doParse(invalidSample, base); |
| 122 } on FormatException { | 124 } on FormatException { |
| 123 // expected | 125 // expected |
| 124 return; | 126 return; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 "foobar=baz.dart", // no colon (but an equals, which is not the same) | 158 "foobar=baz.dart", // no colon (but an equals, which is not the same) |
| 157 ".:../test/", // dot segment | 159 ".:../test/", // dot segment |
| 158 "..:../test/", // dot-dot segment | 160 "..:../test/", // dot-dot segment |
| 159 "...:../test/", // dot-dot-dot segment | 161 "...:../test/", // dot-dot-dot segment |
| 160 "foo/bar:../test/", // slash in name | 162 "foo/bar:../test/", // slash in name |
| 161 "/foo:../test/", // slash at start of name | 163 "/foo:../test/", // slash at start of name |
| 162 "?:../test/", // invalid characters. | 164 "?:../test/", // invalid characters. |
| 163 "[:../test/", // invalid characters. | 165 "[:../test/", // invalid characters. |
| 164 "x#:../test/", // invalid characters. | 166 "x#:../test/", // invalid characters. |
| 165 ]; | 167 ]; |
| OLD | NEW |