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 /// Test [source_update.dart]. | 5 /// Test [source_update.dart]. |
6 library trydart.source_update_test; | 6 library trydart.source_update_test; |
7 | 7 |
8 import 'dart:convert' show | 8 import 'dart:convert' show |
9 JSON; | 9 JSON; |
10 | 10 |
11 import 'package:expect/expect.dart' show | 11 import 'package:expect/expect.dart' show |
12 Expect; | 12 Expect; |
13 | 13 |
14 import 'source_update.dart' show | 14 import 'source_update.dart' show |
| 15 expandDiff, |
15 expandUpdates, | 16 expandUpdates, |
16 splitFiles, | 17 splitFiles, |
17 splitLines; | 18 splitLines; |
18 | 19 |
19 main() { | 20 main() { |
20 Expect.listEquals( | 21 Expect.listEquals( |
21 ["head v1 tail", "head v2 tail"], | 22 ["head v1 tail", "head v2 tail"], |
22 expandUpdates(["head ", ["v1", "v2"], " tail"])); | 23 expandUpdates(["head ", ["v1", "v2"], " tail"])); |
23 | 24 |
24 Expect.listEquals( | 25 Expect.listEquals( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 62 |
62 Expect.stringEquals("{}", JSON.encode(splitFiles(""))); | 63 Expect.stringEquals("{}", JSON.encode(splitFiles(""))); |
63 | 64 |
64 Expect.stringEquals("[]", JSON.encode(splitLines(""))); | 65 Expect.stringEquals("[]", JSON.encode(splitLines(""))); |
65 | 66 |
66 Expect.stringEquals('["1"]', JSON.encode(splitLines("1"))); | 67 Expect.stringEquals('["1"]', JSON.encode(splitLines("1"))); |
67 | 68 |
68 Expect.stringEquals('["\\n"]', JSON.encode(splitLines("\n"))); | 69 Expect.stringEquals('["\\n"]', JSON.encode(splitLines("\n"))); |
69 | 70 |
70 Expect.stringEquals('["\\n","1"]', JSON.encode(splitLines("\n1"))); | 71 Expect.stringEquals('["\\n","1"]', JSON.encode(splitLines("\n1"))); |
| 72 |
| 73 Expect.stringEquals( |
| 74 '["","",""]', |
| 75 JSON.encode(expandUpdates(expandDiff(r""" |
| 76 <<<<<<< |
| 77 ======= |
| 78 ======= |
| 79 >>>>>>> |
| 80 """)))); |
| 81 |
| 82 Expect.stringEquals( |
| 83 r'["first\nv1\nlast\n","first\nv2\nlast\n","first\nv3\nlast\n"]', |
| 84 JSON.encode(expandUpdates(expandDiff(r""" |
| 85 first |
| 86 <<<<<<< |
| 87 v1 |
| 88 ======= |
| 89 v2 |
| 90 ======= |
| 91 v3 |
| 92 >>>>>>> |
| 93 last |
| 94 """)))); |
| 95 |
| 96 Expect.stringEquals( |
| 97 r'["v1\nlast\n","v2\nlast\n","v3\nlast\n"]', |
| 98 JSON.encode(expandUpdates(expandDiff(r""" |
| 99 <<<<<<< |
| 100 v1 |
| 101 ======= |
| 102 v2 |
| 103 ======= |
| 104 v3 |
| 105 >>>>>>> |
| 106 last |
| 107 """)))); |
| 108 |
| 109 Expect.stringEquals( |
| 110 r'["v1\n","v2\n","v3\n"]', |
| 111 JSON.encode(expandUpdates(expandDiff(r""" |
| 112 <<<<<<< |
| 113 v1 |
| 114 ======= |
| 115 v2 |
| 116 ======= |
| 117 v3 |
| 118 >>>>>>> |
| 119 """)))); |
71 } | 120 } |
OLD | NEW |