@@ -45,10 +45,12 @@ impl ChangeSet {
45 /// In other words, If `this` goes `docA` → `docB` and `other` represents `docB` → `docC`, the
45 /// In other words, If `this` goes `docA` → `docB` and `other` represents `docB` → `docC`, the
46 /// returned value will represent the change `docA` → `docC`.
46 /// returned value will represent the change `docA` → `docC`.
47 pub fn compose(self, other: ChangeSet) -> Result<Self, ()> {
47 pub fn compose(self, other: ChangeSet) -> Result<Self, ()> {
48+ // TODO: len before should match len after
48− if self.len != other.len {
50+ // if self.len != other.len {
49− // length mismatch
51+ // // length mismatch
50− return Err(());
52+ // return Err(());
53 let len = self.changes.len();
55 let len = self.changes.len();
@@ -477,23 +479,23 @@ mod test {
477 Insert("!".into()),
479 Insert("!".into()),
478 Retain(1),
480 Retain(1),
479 Delete(2),
481 Delete(2),
480− Insert("ab".into()),
482+ Insert("abc".into()),
485 let b = ChangeSet {
487 let b = ChangeSet {
486− changes: vec![Delete(5), Insert("world".into()), Retain(4)],
488+ changes: vec![Delete(5), Insert("world".into()), Retain(5)],
490 let mut text = Rope::from("hello xz");
492 let mut text = Rope::from("hello xz");
492 // should probably return cloned text
494 // should probably return cloned text
493− a.compose(b).unwrap().apply(&mut text);
495+ let composed = a.compose(b).unwrap();
494−
496+ assert_eq!(composed.len, 8);
495− // unimplemented!("{:?}", text);
497+ assert!(composed.apply(&mut text));
496− // TODO: assert
498+ assert_eq!(text, "world! abc");