mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
Changeset: Move out obsolete code
This commit is contained in:
parent
2155e216a6
commit
eb495e9ea2
2 changed files with 25 additions and 30 deletions
|
@ -31,6 +31,18 @@ function random() {
|
||||||
this.nextDouble = (maxValue) => Math.random();
|
this.nextDouble = (maxValue) => Math.random();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts stuff before $ to base 10
|
||||||
|
* @param cs {string} the string
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
const toBaseTen = (cs) => {
|
||||||
|
const dollarIndex = cs.indexOf('$');
|
||||||
|
const beforeDollar = cs.substring(0, dollarIndex);
|
||||||
|
const fromDollar = cs.substring(dollarIndex);
|
||||||
|
return beforeDollar.replace(/[0-9a-z]+/g, (s) => String(Changeset.parseNum(s))) + fromDollar;
|
||||||
|
};
|
||||||
|
|
||||||
const runTests = () => {
|
const runTests = () => {
|
||||||
const print = (str) => {
|
const print = (str) => {
|
||||||
console.log(str);
|
console.log(str);
|
||||||
|
@ -602,9 +614,9 @@ const runTests = () => {
|
||||||
const change3 = x3[0];
|
const change3 = x3[0];
|
||||||
const text3 = x3[1];
|
const text3 = x3[1];
|
||||||
|
|
||||||
// print(literal(Changeset.toBaseTen(startText)));
|
// print(literal(toBaseTen(startText)));
|
||||||
// print(literal(Changeset.toBaseTen(change1)));
|
// print(literal(toBaseTen(change1)));
|
||||||
// print(literal(Changeset.toBaseTen(change2)));
|
// print(literal(toBaseTen(change2)));
|
||||||
const change12 = Changeset.checkRep(Changeset.compose(change1, change2, p));
|
const change12 = Changeset.checkRep(Changeset.compose(change1, change2, p));
|
||||||
const change23 = Changeset.checkRep(Changeset.compose(change2, change3, p));
|
const change23 = Changeset.checkRep(Changeset.compose(change2, change3, p));
|
||||||
const change123 = Changeset.checkRep(Changeset.compose(change12, change3, p));
|
const change123 = Changeset.checkRep(Changeset.compose(change12, change3, p));
|
||||||
|
@ -769,22 +781,24 @@ const runTests = () => {
|
||||||
p.putAttrib(['name', 'david']);
|
p.putAttrib(['name', 'david']);
|
||||||
p.putAttrib(['color', 'green']);
|
p.putAttrib(['color', 'green']);
|
||||||
|
|
||||||
|
const stringOp = (str) => Changeset.opIterator(str).next();
|
||||||
|
|
||||||
assertEqualStrings('david',
|
assertEqualStrings('david',
|
||||||
Changeset.opAttributeValue(Changeset.stringOp('*0*1+1'), 'name', p));
|
Changeset.opAttributeValue(stringOp('*0*1+1'), 'name', p));
|
||||||
assertEqualStrings('david',
|
assertEqualStrings('david',
|
||||||
Changeset.opAttributeValue(Changeset.stringOp('*0+1'), 'name', p));
|
Changeset.opAttributeValue(stringOp('*0+1'), 'name', p));
|
||||||
assertEqualStrings('',
|
assertEqualStrings('',
|
||||||
Changeset.opAttributeValue(Changeset.stringOp('*1+1'), 'name', p));
|
Changeset.opAttributeValue(stringOp('*1+1'), 'name', p));
|
||||||
assertEqualStrings('',
|
assertEqualStrings('',
|
||||||
Changeset.opAttributeValue(Changeset.stringOp('+1'), 'name', p));
|
Changeset.opAttributeValue(stringOp('+1'), 'name', p));
|
||||||
assertEqualStrings('green',
|
assertEqualStrings('green',
|
||||||
Changeset.opAttributeValue(Changeset.stringOp('*0*1+1'), 'color', p));
|
Changeset.opAttributeValue(stringOp('*0*1+1'), 'color', p));
|
||||||
assertEqualStrings('green',
|
assertEqualStrings('green',
|
||||||
Changeset.opAttributeValue(Changeset.stringOp('*1+1'), 'color', p));
|
Changeset.opAttributeValue(stringOp('*1+1'), 'color', p));
|
||||||
assertEqualStrings('',
|
assertEqualStrings('',
|
||||||
Changeset.opAttributeValue(Changeset.stringOp('*0+1'), 'color', p));
|
Changeset.opAttributeValue(stringOp('*0+1'), 'color', p));
|
||||||
assertEqualStrings('',
|
assertEqualStrings('',
|
||||||
Changeset.opAttributeValue(Changeset.stringOp('+1'), 'color', p));
|
Changeset.opAttributeValue(stringOp('+1'), 'color', p));
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const testAppendATextToAssembler = (testId, atext, correctOps) => {
|
const testAppendATextToAssembler = (testId, atext, correctOps) => {
|
||||||
|
|
|
@ -70,20 +70,6 @@ exports.parseNum = (str) => parseInt(str, 36);
|
||||||
*/
|
*/
|
||||||
exports.numToString = (num) => num.toString(36).toLowerCase();
|
exports.numToString = (num) => num.toString(36).toLowerCase();
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts stuff before $ to base 10
|
|
||||||
* @obsolete not really used anywhere??
|
|
||||||
* @param cs {string} the string
|
|
||||||
* @return integer
|
|
||||||
*/
|
|
||||||
exports.toBaseTen = (cs) => {
|
|
||||||
const dollarIndex = cs.indexOf('$');
|
|
||||||
const beforeDollar = cs.substring(0, dollarIndex);
|
|
||||||
const fromDollar = cs.substring(dollarIndex);
|
|
||||||
return beforeDollar.replace(/[0-9a-z]+/g, (s) => String(exports.parseNum(s))) + fromDollar;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ==================== Changeset Functions =======================
|
* ==================== Changeset Functions =======================
|
||||||
*/
|
*/
|
||||||
|
@ -207,11 +193,6 @@ exports.opString = (op) => {
|
||||||
return assem.toString();
|
return assem.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Used just for debugging
|
|
||||||
*/
|
|
||||||
exports.stringOp = (str) => exports.opIterator(str).next();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to check if a Changeset if valid
|
* Used to check if a Changeset if valid
|
||||||
* @param cs {Changeset} Changeset to be checked
|
* @param cs {Changeset} Changeset to be checked
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue