OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 void testInvalidArguments() { | 7 void testInvalidArguments() { |
8 } | 8 } |
9 | 9 |
10 void testPath() { | 10 void testPath() { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 if (pchar.indexOf(new String.fromCharCode(i)) != -1) { | 63 if (pchar.indexOf(new String.fromCharCode(i)) != -1) { |
64 encoded.writeCharCode(i); | 64 encoded.writeCharCode(i); |
65 } else { | 65 } else { |
66 encoded.write("%"); | 66 encoded.write("%"); |
67 encoded.write(i.toRadixString(16).toUpperCase()); | 67 encoded.write(i.toRadixString(16).toUpperCase()); |
68 } | 68 } |
69 unencoded.writeCharCode(i); | 69 unencoded.writeCharCode(i); |
70 } | 70 } |
71 encoded = encoded.toString(); | 71 encoded = encoded.toString(); |
72 unencoded = unencoded.toString(); | 72 unencoded = unencoded.toString(); |
73 print(encoded); | |
74 print(unencoded); | |
75 test(encoded, [unencoded]); | 73 test(encoded, [unencoded]); |
76 test(encoded + "/" + encoded, [unencoded, unencoded]); | 74 test(encoded + "/" + encoded, [unencoded, unencoded]); |
77 } | 75 } |
78 | 76 |
| 77 testPathSegmentsUnmodifiableList() { |
| 78 |
| 79 test(list) { |
| 80 bool isUnsupported(e) => e is UnsupportedError; |
| 81 |
| 82 Expect.equals("a", list[0]); |
| 83 Expect.throws(() => list[0] = "c", isUnsupported); |
| 84 Expect.equals(2, list.length); |
| 85 Expect.throws(() => list.length = 1, isUnsupported); |
| 86 Expect.throws(() => list.add("c"), isUnsupported); |
| 87 Expect.throws(() => list.addAll(["c", "d"]), isUnsupported); |
| 88 Expect.listEquals(["b", "a"], list.reversed.toList()); |
| 89 Expect.throws(() => list.sort(), isUnsupported); |
| 90 Expect.equals(0, list.indexOf("a")); |
| 91 Expect.equals(0, list.lastIndexOf("a")); |
| 92 Expect.throws(() => list.clear(), isUnsupported); |
| 93 Expect.throws(() => list.insert(1, "c"), isUnsupported); |
| 94 Expect.throws(() => list.insertAll(1, ["c", "d"]), isUnsupported); |
| 95 Expect.throws(() => list.setAll(1, ["c", "d"]), isUnsupported); |
| 96 Expect.throws(() => list.remove("a"), isUnsupported); |
| 97 Expect.throws(() => list.removeAt(0), isUnsupported); |
| 98 Expect.throws(() => list.removeLast(), isUnsupported); |
| 99 Expect.throws(() => list.removeWhere((e) => true), isUnsupported); |
| 100 Expect.throws(() => list.retainWhere((e) => false), isUnsupported); |
| 101 Expect.listEquals(["a"], list.sublist(0, 1)); |
| 102 Expect.listEquals(["a"], list.getRange(0, 1).toList()); |
| 103 Expect.throws(() => list.setRange(0, 1, ["c"]), isUnsupported); |
| 104 Expect.throws(() => list.removeRange(0, 1), isUnsupported); |
| 105 Expect.throws(() => list.fillRange(0, 1, "c"), isUnsupported); |
| 106 Expect.throws(() => list.replaceRange(0, 1, ["c"]), isUnsupported); |
| 107 Map map = new Map(); |
| 108 map[0] = "a"; |
| 109 map[1] = "b"; |
| 110 Expect.mapEquals(list.asMap(), map); |
| 111 } |
| 112 |
| 113 test(Uri.parse("a/b").pathSegments); |
| 114 test(new Uri(pathSegments: ["a", "b"]).pathSegments); |
| 115 } |
| 116 |
79 main() { | 117 main() { |
80 testInvalidArguments(); | 118 testInvalidArguments(); |
81 testPath(); | 119 testPath(); |
82 testPathSegments(); | 120 testPathSegments(); |
| 121 testPathSegmentsUnmodifiableList(); |
83 } | 122 } |
OLD | NEW |