| 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 |
| 9 JSON; |
| 10 |
| 8 import 'package:expect/expect.dart' show | 11 import 'package:expect/expect.dart' show |
| 9 Expect; | 12 Expect; |
| 10 | 13 |
| 11 import 'source_update.dart' show | 14 import 'source_update.dart' show |
| 12 expandUpdates; | 15 expandUpdates, |
| 16 splitFiles, |
| 17 splitLines; |
| 13 | 18 |
| 14 main() { | 19 main() { |
| 15 Expect.listEquals( | 20 Expect.listEquals( |
| 16 ["head v1 tail", "head v2 tail"], | 21 ["head v1 tail", "head v2 tail"], |
| 17 expandUpdates(["head ", ["v1", "v2"], " tail"])); | 22 expandUpdates(["head ", ["v1", "v2"], " tail"])); |
| 18 | 23 |
| 19 Expect.listEquals( | 24 Expect.listEquals( |
| 20 ["head v1 tail v2", "head v2 tail v1"], | 25 ["head v1 tail v2", "head v2 tail v1"], |
| 21 expandUpdates(["head ", ["v1", "v2"], " tail ", ["v2", "v1"]])); | 26 expandUpdates(["head ", ["v1", "v2"], " tail ", ["v2", "v1"]])); |
| 22 | 27 |
| 23 Expect.throws(() { | 28 Expect.throws(() { |
| 24 expandUpdates(["head ", ["v1", "v2"], " tail ", ["v1"]]); | 29 expandUpdates(["head ", ["v1", "v2"], " tail ", ["v1"]]); |
| 25 }); | 30 }); |
| 26 | 31 |
| 27 Expect.throws(() { | 32 Expect.throws(() { |
| 28 expandUpdates(["head ", ["v1", "v2"], " tail ", ["v1", "v2", "v3"]]); | 33 expandUpdates(["head ", ["v1", "v2"], " tail ", ["v1", "v2", "v3"]]); |
| 29 }); | 34 }); |
| 35 |
| 36 Expect.stringEquals( |
| 37 JSON.encode({ |
| 38 "file1.dart": """ |
| 39 First line of file 1. |
| 40 Second line of file 1. |
| 41 Third line of file 1. |
| 42 """, |
| 43 "empty.dart":"", |
| 44 "file2.dart":""" |
| 45 First line of file 2. |
| 46 Second line of file 2. |
| 47 Third line of file 2. |
| 48 """}), |
| 49 |
| 50 JSON.encode(splitFiles(r""" |
| 51 ==> file1.dart <== |
| 52 First line of file 1. |
| 53 Second line of file 1. |
| 54 Third line of file 1. |
| 55 ==> empty.dart <== |
| 56 ==> file2.dart <== |
| 57 First line of file 2. |
| 58 Second line of file 2. |
| 59 Third line of file 2. |
| 60 """))); |
| 61 |
| 62 Expect.stringEquals("{}", JSON.encode(splitFiles(""))); |
| 63 |
| 64 Expect.stringEquals("[]", JSON.encode(splitLines(""))); |
| 65 |
| 66 Expect.stringEquals('["1"]', JSON.encode(splitLines("1"))); |
| 67 |
| 68 Expect.stringEquals('["\\n"]', JSON.encode(splitLines("\n"))); |
| 69 |
| 70 Expect.stringEquals('["\\n","1"]', JSON.encode(splitLines("\n1"))); |
| 30 } | 71 } |
| OLD | NEW |