added tests for observer types

This commit is contained in:
DadaMonad
2014-12-24 11:35:06 +00:00
parent 2f47ad9e3a
commit fd1128d456
33 changed files with 607 additions and 240 deletions

View File

@@ -24,7 +24,7 @@
};
Operation.prototype.unobserve = function(f) {
return this.event_listeners.filter(function(g) {
return this.event_listeners = this.event_listeners.filter(function(g) {
return f !== g;
});
};
@@ -156,9 +156,13 @@
};
Delete.prototype.execute = function() {
var res;
if (this.validateSavedOperations()) {
this.deletes.applyDelete(this);
return Delete.__super__.execute.apply(this, arguments);
res = Delete.__super__.execute.apply(this, arguments);
if (res) {
this.deletes.applyDelete(this);
}
return res;
} else {
return false;
}
@@ -307,7 +311,8 @@
type: "insert",
position: this.getPosition(),
object: this.parent,
changed_by: this.uid.creator
changed_by: this.uid.creator,
value: this.content
}
]) : void 0;
};

File diff suppressed because one or more lines are too long

View File

@@ -195,22 +195,21 @@
ListManager.prototype.getOperationByPosition = function(position) {
var o;
o = this.beginning.next_cl;
if ((position > 0 || o.isDeleted()) && !(o instanceof types.Delimiter)) {
while (o.isDeleted() && !(o instanceof types.Delimiter)) {
o = o.next_cl;
o = this.beginning;
while (true) {
if (o instanceof types.Delimiter && (o.prev_cl != null)) {
o = o.prev_cl;
while (o.isDeleted() || !(o instanceof types.Delimiter)) {
o = o.prev_cl;
}
break;
}
while (true) {
if (o instanceof types.Delimiter) {
break;
}
if (position <= 0 && !o.isDeleted()) {
break;
}
o = o.next_cl;
if (!o.isDeleted()) {
position -= 1;
}
if (position <= 0 && !o.isDeleted()) {
break;
}
o = o.next_cl;
if (!o.isDeleted()) {
position -= 1;
}
}
return o;

File diff suppressed because one or more lines are too long

View File

@@ -147,15 +147,14 @@
};
WordType.prototype.insertText = function(position, content) {
var ith, left;
var ith;
ith = this.getOperationByPosition(position);
left = ith.prev_cl;
return this.insertAfter(left, content);
return this.insertAfter(ith, content);
};
WordType.prototype.deleteText = function(position, length) {
var d, delete_ops, i, o, _i;
o = this.getOperationByPosition(position);
o = this.getOperationByPosition(position + 1);
delete_ops = [];
for (i = _i = 0; 0 <= length ? _i < length : _i > length; i = 0 <= length ? ++_i : --_i) {
if (o instanceof types.Delimiter) {

File diff suppressed because one or more lines are too long