2012-02-07 00:12:31 +00:00
|
|
|
module( 've' );
|
2011-11-02 21:20:55 +00:00
|
|
|
|
2011-11-04 18:08:51 +00:00
|
|
|
/* Stubs */
|
|
|
|
|
2012-02-07 00:12:31 +00:00
|
|
|
function BranchNodeStub( items, name, size ) {
|
2011-11-03 21:48:40 +00:00
|
|
|
// Inheritance
|
2012-02-07 00:12:31 +00:00
|
|
|
ve.BranchNode.call( this, items );
|
2011-11-03 21:48:40 +00:00
|
|
|
|
|
|
|
// Properties
|
2011-11-02 21:20:55 +00:00
|
|
|
this.name = name;
|
|
|
|
this.size = size;
|
|
|
|
}
|
|
|
|
|
2012-02-07 00:12:31 +00:00
|
|
|
BranchNodeStub.prototype.getContentLength = function() {
|
2011-11-02 21:20:55 +00:00
|
|
|
return this.size;
|
|
|
|
};
|
|
|
|
|
2012-02-07 00:12:31 +00:00
|
|
|
BranchNodeStub.prototype.getElementLength = function() {
|
2011-11-02 21:20:55 +00:00
|
|
|
// Mimic document data which has an opening and closing around the content
|
|
|
|
return this.size + 2;
|
|
|
|
};
|
|
|
|
|
2012-02-07 00:12:31 +00:00
|
|
|
ve.extendClass( BranchNodeStub, ve.BranchNode );
|
2011-11-03 21:48:40 +00:00
|
|
|
|
2011-11-04 18:08:51 +00:00
|
|
|
/* Tests */
|
2011-11-02 21:20:55 +00:00
|
|
|
|
2012-02-07 00:12:31 +00:00
|
|
|
test( 've.BranchNodeStub.getElementLength', 1, function() {
|
2011-11-04 18:08:51 +00:00
|
|
|
// Test 1
|
2011-11-02 21:20:55 +00:00
|
|
|
strictEqual(
|
2012-02-07 00:12:31 +00:00
|
|
|
( new BranchNodeStub( [], 'a', 0 ) ).getElementLength(),
|
2011-11-02 21:20:55 +00:00
|
|
|
2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'BranchNodeStub.getElementLength() returns initialized length plus 2 for elements'
|
2011-11-02 21:20:55 +00:00
|
|
|
);
|
2011-11-04 18:08:51 +00:00
|
|
|
} );
|
2011-11-02 21:20:55 +00:00
|
|
|
|
2011-11-04 18:08:51 +00:00
|
|
|
// Common stubs
|
2012-02-07 00:12:31 +00:00
|
|
|
var a = new BranchNodeStub( [], 'a', 0 ),
|
|
|
|
b = new BranchNodeStub( [], 'b', 1 ),
|
|
|
|
c = new BranchNodeStub( [], 'c', 2 ),
|
|
|
|
d = new BranchNodeStub( [], 'd', 3 ),
|
|
|
|
e = new BranchNodeStub( [], 'e', 4 ),
|
|
|
|
root1 = new BranchNodeStub( [a, b, c, d, e], 'root1', 20 );
|
2011-11-02 21:20:55 +00:00
|
|
|
|
2012-02-07 00:12:31 +00:00
|
|
|
test( 've.BranchNode.getRangeFromNode', 6, function() {
|
2011-11-04 18:08:51 +00:00
|
|
|
// Tests 1 .. 6
|
2011-11-02 21:20:55 +00:00
|
|
|
var getRangeFromNodeTests = [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'input': a, 'output': new ve.Range( 0, 2 ) },
|
|
|
|
{ 'input': b, 'output': new ve.Range( 2, 5 ) },
|
|
|
|
{ 'input': c, 'output': new ve.Range( 5, 9 ) },
|
|
|
|
{ 'input': d, 'output': new ve.Range( 9, 14 ) },
|
|
|
|
{ 'input': e, 'output': new ve.Range( 14, 20 ) },
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': null, 'output': null }
|
|
|
|
];
|
2011-11-04 18:08:51 +00:00
|
|
|
for ( var i = 0; i < getRangeFromNodeTests.length; i++ ) {
|
2011-11-02 21:20:55 +00:00
|
|
|
deepEqual(
|
|
|
|
root1.getRangeFromNode( getRangeFromNodeTests[i].input ),
|
|
|
|
getRangeFromNodeTests[i].output,
|
|
|
|
'getRangeFromNode returns the correct range or null if item is not found'
|
|
|
|
);
|
|
|
|
}
|
2011-11-04 18:08:51 +00:00
|
|
|
} );
|
2011-11-02 21:20:55 +00:00
|
|
|
|
2012-02-07 00:12:31 +00:00
|
|
|
test( 've.BranchNode.getNodeFromOffset', 23, function() {
|
2011-11-04 18:08:51 +00:00
|
|
|
// Tests 1 .. 22
|
2011-11-02 21:20:55 +00:00
|
|
|
var getNodeFromOffsetTests = [
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 1 - |[<a></a><b> </b><c> </c><d> </d><e> </e>]
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': -1, 'output': null },
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 2 - [|<a></a><b> </b><c> </c><d> </d><e> </e>]
|
|
|
|
{ 'input': 0, 'output': root1 },
|
|
|
|
// Test 3 - [<a>|</a><b> </b><c> </c><d> </d><e> </e>]
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': 1, 'output': a },
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 4 - [<a></a>|<b> </b><c> </c><d> </d><e> </e>]
|
|
|
|
{ 'input': 2, 'output': root1 },
|
|
|
|
// Test 5 - [<a></a><b>| </b><c> </c><d> </d><e> </e>]
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': 3, 'output': b },
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 6 - [<a></a><b> |</b><c> </c><d> </d><e> </e>]
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': 4, 'output': b },
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 7 - [<a></a><b> </b>|<c> </c><d> </d><e> </e>]
|
|
|
|
{ 'input': 5, 'output': root1 },
|
|
|
|
// Test 8 - [<a></a><b> </b><c>| </c><d> </d><e> </e>]
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': 6, 'output': c },
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 9 - [<a></a><b> </b><c> | </c><d> </d><e> </e>]
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': 7, 'output': c },
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 10 - [<a></a><b> </b><c> |</c><d> </d><e> </e>]
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': 8, 'output': c },
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 11 - [<a></a><b> </b><c> </c>|<d> </d><e> </e>]
|
|
|
|
{ 'input': 9, 'output': root1 },
|
|
|
|
// Test 12 - [<a></a><b> </b><c> </c><d>| </d><e> </e>]
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': 10, 'output': d },
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 13 - [<a></a><b> </b><c> </c><d> | </d><e> </e>]
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': 11, 'output': d },
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 14 - [<a></a><b> </b><c> </c><d> | </d><e> </e>]
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': 12, 'output': d },
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 15 - [<a></a><b> </b><c> </c><d> |</d><e> </e>]
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': 13, 'output': d },
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 16 - [<a></a><b> </b><c> </c><d> </d>|<e> </e>]
|
|
|
|
{ 'input': 14, 'output': root1 },
|
|
|
|
// Test 17 - [<a></a><b> </b><c> </c><d> </d><e>| </e>]
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': 15, 'output': e },
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 18 - [<a></a><b> </b><c> </c><d> </d><e> | </e>]
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': 16, 'output': e },
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 19 - [<a></a><b> </b><c> </c><d> </d><e> | </e>]
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': 17, 'output': e },
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 20 - [<a></a><b> </b><c> </c><d> </d><e> | </e>]
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': 18, 'output': e },
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 21 - [<a></a><b> </b><c> </c><d> </d><e> |</e>]
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'input': 19, 'output': e },
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 22 - [<a></a><b> </b><c> </c><d> </d><e> </e>|]
|
|
|
|
{ 'input': 20, 'output': root1 },
|
|
|
|
// Test 22 - [<a></a><b> </b><c> </c><d> </d><e> </e>]|
|
|
|
|
{ 'input': 21, 'output': null }
|
2011-11-02 21:20:55 +00:00
|
|
|
];
|
2011-11-04 18:08:51 +00:00
|
|
|
for ( var i = 0; i < getNodeFromOffsetTests.length; i++ ) {
|
2011-11-09 23:39:47 +00:00
|
|
|
ok(
|
|
|
|
root1.getNodeFromOffset( getNodeFromOffsetTests[i].input ) ===
|
2011-11-02 21:20:55 +00:00
|
|
|
getNodeFromOffsetTests[i].output,
|
2011-11-09 23:39:47 +00:00
|
|
|
'getNodeFromOffset finds the right item or returns null when out of range ' +
|
|
|
|
'(' + getNodeFromOffsetTests[i].input + ')'
|
2011-11-02 21:20:55 +00:00
|
|
|
);
|
|
|
|
}
|
2011-11-04 18:08:51 +00:00
|
|
|
} );
|
2011-11-02 21:20:55 +00:00
|
|
|
|
2012-02-07 00:12:31 +00:00
|
|
|
test( 've.BranchNode.getOffsetFromNode', 6, function() {
|
2011-11-04 18:08:51 +00:00
|
|
|
// Tests 1 .. 6
|
2011-11-02 21:20:55 +00:00
|
|
|
var getOffsetFromNodeTests = [
|
|
|
|
{ 'input': a, 'output': 0 },
|
|
|
|
{ 'input': b, 'output': 2 },
|
|
|
|
{ 'input': c, 'output': 5 },
|
|
|
|
{ 'input': d, 'output': 9 },
|
|
|
|
{ 'input': e, 'output': 14 },
|
|
|
|
{ 'input': null, 'output': -1 }
|
|
|
|
];
|
2011-11-04 18:08:51 +00:00
|
|
|
for ( var i = 0; i < getOffsetFromNodeTests.length; i++ ) {
|
2011-11-02 21:20:55 +00:00
|
|
|
strictEqual(
|
|
|
|
root1.getOffsetFromNode( getOffsetFromNodeTests[i].input ),
|
|
|
|
getOffsetFromNodeTests[i].output,
|
|
|
|
'getOffsetFromNode finds the right offset or returns -1 when node is not found'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2012-02-07 00:12:31 +00:00
|
|
|
test( 've.BranchNode.selectNodes', 77, function() {
|
2011-11-02 21:20:55 +00:00
|
|
|
|
|
|
|
// selectNodes tests
|
|
|
|
|
|
|
|
// <f> a b c d e f g h </f> <g> a b c d e f g h </g> <h> a b c d e f g h </h>
|
|
|
|
//^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
|
|
|
|
//0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
|
|
|
|
// 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8
|
2012-02-07 00:12:31 +00:00
|
|
|
var f = new BranchNodeStub( [], 'f', 8 ),
|
|
|
|
g = new BranchNodeStub( [], 'g', 8 ),
|
|
|
|
h = new BranchNodeStub( [], 'h', 8 ),
|
|
|
|
root2 = new BranchNodeStub( [f, g, h], 'root2', 30 ),
|
|
|
|
big = ve.dm.DocumentNode.newFromPlainObject( veTest.obj );
|
2011-11-02 21:20:55 +00:00
|
|
|
|
2011-11-04 18:08:51 +00:00
|
|
|
// Tests 1 ... 22
|
2011-11-02 21:20:55 +00:00
|
|
|
// Possible positions are:
|
|
|
|
// * before beginning
|
|
|
|
// * at beginning
|
|
|
|
// * middle
|
|
|
|
// * at end
|
|
|
|
// * past end
|
|
|
|
var selectNodesTests = [
|
|
|
|
// Complete set of combinations within the same node:
|
2011-11-09 23:39:47 +00:00
|
|
|
|
|
|
|
// Test 1
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 0, 0 ),
|
|
|
|
'output': [{ 'node': root2, 'range': new ve.Range( 0, 0 ), 'globalRange': new ve.Range( 0, 0 ) }],
|
2011-11-02 21:20:55 +00:00
|
|
|
'desc': 'Zero-length range before the beginning of a node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 2
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 0, 1 ),
|
|
|
|
'output': [{ 'node': f, 'range': new ve.Range( 0, 0 ), 'globalRange': new ve.Range( 1, 1 ) }],
|
2011-11-02 21:20:55 +00:00
|
|
|
'desc': 'Range starting before the beginning of a node and ending at the beginning'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 3
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 10, 15 ),
|
|
|
|
'output': [{ 'node': g, 'range': new ve.Range( 0, 4 ), 'globalRange': new ve.Range( 11, 15 ) }],
|
2011-11-02 21:20:55 +00:00
|
|
|
'desc': 'Range starting before the beginning of a node and ending in the middle'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 4
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 20, 29 ),
|
|
|
|
'output': [{ 'node': h, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 21, 29 ) }],
|
2011-11-02 21:20:55 +00:00
|
|
|
'desc': 'Range starting before the beginning of a node and ending at the end'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 5
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 0, 10 ),
|
|
|
|
'output': [{ 'node': f, 'globalRange': new ve.Range( 0, 10 ) } ],
|
2011-11-02 21:20:55 +00:00
|
|
|
'desc': 'Range starting before the beginning of a node and ending past the end'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 6
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 11, 11 ),
|
|
|
|
'output': [{ 'node': g, 'range': new ve.Range( 0, 0 ), 'globalRange': new ve.Range( 11, 11 ) }],
|
2011-11-02 21:20:55 +00:00
|
|
|
'desc': 'Zero-length range at the beginning of a node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 7
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 21, 26 ),
|
|
|
|
'output': [{ 'node': h, 'range': new ve.Range( 0, 5 ), 'globalRange': new ve.Range( 21, 26 ) }],
|
2011-11-02 21:20:55 +00:00
|
|
|
'desc': 'Range starting at the beginning of a node and ending in the middle'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 8
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 1, 9 ),
|
|
|
|
'output': [{ 'node': f, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 1, 9 ) }],
|
2011-11-02 21:20:55 +00:00
|
|
|
'desc': 'Range starting at the beginning of a node and ending at the end'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 9
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 11, 20 ),
|
|
|
|
'output': [{ 'node': g, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 11, 19 ) }],
|
2011-11-02 21:20:55 +00:00
|
|
|
'desc': 'Range starting at the beginning of a node and ending past the end'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 10
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 22, 22 ),
|
|
|
|
'output': [{ 'node': h, 'range': new ve.Range( 1, 1 ), 'globalRange': new ve.Range( 22, 22 ) }],
|
2011-11-02 21:20:55 +00:00
|
|
|
'desc': 'Zero-length range in the middle of a node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 11
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 2, 7 ),
|
|
|
|
'output': [{ 'node': f, 'range': new ve.Range( 1, 6 ), 'globalRange': new ve.Range( 2, 7 ) }],
|
2011-11-02 21:20:55 +00:00
|
|
|
'desc': 'Range starting and ending in the middle of the same node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 12
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 13, 19 ),
|
|
|
|
'output': [{ 'node': g, 'range': new ve.Range( 2, 8 ), 'globalRange': new ve.Range( 13, 19 ) }],
|
2011-11-02 21:20:55 +00:00
|
|
|
'desc': 'Range starting in the middle of a node and ending at the end'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 13
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 24, 30 ),
|
|
|
|
'output': [{ 'node': h, 'range': new ve.Range( 3, 8 ), 'globalRange': new ve.Range( 24, 29 ) }],
|
2011-11-02 21:20:55 +00:00
|
|
|
'desc': 'Range starting in the middle of a node and ending past the end'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 14
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 9, 9 ),
|
|
|
|
'output': [{ 'node': f, 'range': new ve.Range( 8, 8 ), 'globalRange': new ve.Range( 9, 9 ) }],
|
2011-11-02 21:20:55 +00:00
|
|
|
'desc': 'Zero-length range at the end of a node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 15
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 19, 20 ),
|
|
|
|
'output': [{ 'node': g, 'range': new ve.Range( 8, 8 ), 'globalRange': new ve.Range( 19, 19 ) }],
|
2011-11-02 21:20:55 +00:00
|
|
|
'desc': 'Range starting at the end of a node and ending past the end'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 16
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 30, 30 ),
|
|
|
|
'output': [{ 'node': root2, 'range': new ve.Range( 30, 30 ), 'globalRange': new ve.Range( 30, 30 ) }],
|
2011-11-02 21:20:55 +00:00
|
|
|
'desc': 'Zero-length range past the end of a node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 17
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 20, 20 ),
|
|
|
|
'output': [{ 'node': root2, 'range': new ve.Range( 20, 20 ), 'globalRange': new ve.Range( 20, 20 ) }],
|
2011-11-04 20:27:23 +00:00
|
|
|
'desc': 'Zero-length range between two nodes'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
|
2011-11-04 20:27:23 +00:00
|
|
|
// Complete set of combinations for cross-node selections. Generated with help of a script
|
2011-11-09 23:39:47 +00:00
|
|
|
|
|
|
|
// Test 18
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 0, 11 ),
|
2011-11-02 21:20:55 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'globalRange': new ve.Range( 0, 10 ) },
|
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 0 ), 'globalRange': new ve.Range( 11, 11 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting before the beginning of the first node and ending at the beginning of the second node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 19
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 0, 14 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'globalRange': new ve.Range( 0, 10 ) },
|
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 3 ), 'globalRange': new ve.Range( 11, 14 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting before the beginning of the first node and ending in the middle of the second node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 20
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 0, 19 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'globalRange': new ve.Range( 0, 10 ) },
|
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 11, 19 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting before the beginning of the first node and ending at the end of the second node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 21
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 0, 20 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'globalRange': new ve.Range( 0, 10 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting before the beginning of the first node and ending between the second and the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 22
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 0, 21 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'globalRange': new ve.Range( 0, 10 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 0 ), 'globalRange': new ve.Range( 21, 21 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting before the beginning of the first node and ending at the beginning of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 23
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 0, 27 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'globalRange': new ve.Range( 0, 10 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 6 ), 'globalRange': new ve.Range( 21, 27 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting before the beginning of the first node and ending in the middle of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 24
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 0, 29 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'globalRange': new ve.Range( 0, 10 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 21, 29 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting before the beginning of the first node and ending at the end of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 25
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 0, 30 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'globalRange': new ve.Range( 0, 10 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'globalRange': new ve.Range( 20, 30 ) }
|
2011-11-02 21:20:55 +00:00
|
|
|
],
|
2011-11-04 20:27:23 +00:00
|
|
|
'desc': 'Range starting before the beginning of the first node and ending past the end of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 26
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 1, 11 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 1, 9 ) },
|
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 0 ), 'globalRange': new ve.Range( 11, 11 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the beginning of the first node and ending at the beginning of the second node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 27
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 1, 14 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 1, 9 ) },
|
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 3 ), 'globalRange': new ve.Range( 11, 14 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the beginning of the first node and ending in the middle of the second node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 28
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 1, 19 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 1, 9 ) },
|
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 11, 19 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the beginning of the first node and ending at the end of the second node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 29
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 1, 20 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 1, 9 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the beginning of the first node and ending between the second and the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 30
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 1, 21 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 1, 9 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 0 ), 'globalRange': new ve.Range( 21, 21 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the beginning of the first node and ending at the beginning of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 31
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 1, 27 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 1, 9 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 6 ), 'globalRange': new ve.Range( 21, 27 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the beginning of the first node and ending in the middle of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 32
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 1, 29 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 1, 9 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 21, 29 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the beginning of the first node and ending at the end of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 33
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 1, 30 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 1, 9 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'globalRange': new ve.Range( 20, 30 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the beginning of the first node and ending past the end of the third node'
|
2011-11-02 21:20:55 +00:00
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 34
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 5, 11 ),
|
2011-11-02 21:20:55 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 4, 8 ), 'globalRange': new ve.Range( 5, 9 ) },
|
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 0 ), 'globalRange': new ve.Range( 11, 11 ) }
|
2011-11-02 21:20:55 +00:00
|
|
|
],
|
2011-11-04 20:27:23 +00:00
|
|
|
'desc': 'Range starting in the middle of the first node and ending at the beginning of the second node'
|
2011-11-02 21:20:55 +00:00
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 35
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 5, 14 ),
|
2011-11-02 21:20:55 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 4, 8 ), 'globalRange': new ve.Range( 5, 9 ) },
|
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 3 ), 'globalRange': new ve.Range( 11, 14 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting in the middle of the first node and ending in the middle of the second node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 36
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 5, 19 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 4, 8 ), 'globalRange': new ve.Range( 5, 9 ) },
|
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 11, 19 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting in the middle of the first node and ending at the end of the second node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 37
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 5, 20 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 4, 8 ), 'globalRange': new ve.Range( 5, 9 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting in the middle of the first node and ending between the second and the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 38
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 5, 21 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 4, 8 ), 'globalRange': new ve.Range( 5, 9 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 0 ), 'globalRange': new ve.Range( 21, 21 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting in the middle of the first node and ending at the beginning of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 39
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 5, 27 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 4, 8 ), 'globalRange': new ve.Range( 5, 9 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 6 ), 'globalRange': new ve.Range( 21, 27 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting in the middle of the first node and ending in the middle of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 40
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 5, 29 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 4, 8 ), 'globalRange': new ve.Range( 5, 9 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 21, 29 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting in the middle of the first node and ending at the end of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 41
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 5, 30 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 4, 8 ), 'globalRange': new ve.Range( 5, 9 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'globalRange': new ve.Range( 20, 30 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting in the middle of the first node and ending past the end of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 42
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 9, 11 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 8, 8 ), 'globalRange': new ve.Range( 9, 9 ) },
|
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 0 ), 'globalRange': new ve.Range( 11, 11 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the end of the first node and ending at the beginning of the second node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 43
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 9, 14 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 8, 8 ), 'globalRange': new ve.Range( 9, 9 ) },
|
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 3 ), 'globalRange': new ve.Range( 11, 14 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the end of the first node and ending in the middle of the second node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 44
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 9, 19 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 8, 8 ), 'globalRange': new ve.Range( 9, 9 ) },
|
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 11, 19 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the end of the first node and ending at the end of the second node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 45
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 9, 20 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 8, 8 ), 'globalRange': new ve.Range( 9, 9 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) }
|
2011-11-02 21:20:55 +00:00
|
|
|
],
|
2011-11-04 20:27:23 +00:00
|
|
|
'desc': 'Range starting at the end of the first node and ending between the second and the third node'
|
2011-11-02 21:20:55 +00:00
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 46
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 9, 21 ),
|
2011-11-02 21:20:55 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 8, 8 ), 'globalRange': new ve.Range( 9, 9 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 0 ), 'globalRange': new ve.Range( 21, 21 ) }
|
2011-11-02 21:20:55 +00:00
|
|
|
],
|
2011-11-04 20:27:23 +00:00
|
|
|
'desc': 'Range starting at the end of the first node and ending at the beginning of the third node'
|
2011-11-02 21:20:55 +00:00
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 47
|
2011-11-02 21:20:55 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 9, 27 ),
|
2011-11-02 21:20:55 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 8, 8 ), 'globalRange': new ve.Range( 9, 9 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 6 ), 'globalRange': new ve.Range( 21, 27 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the end of the first node and ending in the middle of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 48
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 9, 29 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 8, 8 ), 'globalRange': new ve.Range( 9, 9 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 21, 29 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the end of the first node and ending at the end of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 49
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 9, 30 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': f, 'range': new ve.Range( 8, 8 ), 'globalRange': new ve.Range( 9, 9 ) },
|
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'globalRange': new ve.Range( 20, 30 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the end of the first node and ending past the end of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 50
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 10, 21 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 0 ), 'globalRange': new ve.Range( 21, 21 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting between the first and the second node and ending at the beginning of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 51
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 10, 27 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 6 ), 'globalRange': new ve.Range( 21, 27 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting between the first and the second node and ending in the middle of the third node'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 52
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 10, 29 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 21, 29 ) }
|
2011-11-02 21:20:55 +00:00
|
|
|
],
|
2011-11-04 20:27:23 +00:00
|
|
|
'desc': 'Range starting between the first and the second node and ending at the end of the third node'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 53
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 10, 30 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'globalRange': new ve.Range( 10, 20 ) },
|
|
|
|
{ 'node': h, 'globalRange': new ve.Range( 20, 30 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting between the first and the second node and ending past the end of the third node'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 54
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 11, 21 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 11, 19 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 0 ), 'globalRange': new ve.Range( 21, 21 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the beginning of the second node and ending at the beginning of the third node'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 55
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 11, 27 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 11, 19 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 6 ), 'globalRange': new ve.Range( 21, 27 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the beginning of the second node and ending in the middle of the third node'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 56
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 11, 29 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 11, 19 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 21, 29 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the beginning of the second node and ending at the end of the third node'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 57
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 11, 30 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 11, 19 ) },
|
|
|
|
{ 'node': h, 'globalRange': new ve.Range( 20, 30 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the beginning of the second node and ending past the end of the third node'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 58
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 14, 21 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'range': new ve.Range( 3, 8 ), 'globalRange': new ve.Range( 14, 19 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 0 ), 'globalRange': new ve.Range( 21, 21 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting in the middle of the second node and ending at the beginning of the third node'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 59
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 14, 27 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'range': new ve.Range( 3, 8 ), 'globalRange': new ve.Range( 14, 19 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 6 ), 'globalRange': new ve.Range( 21, 27 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting in the middle of the second node and ending in the middle of the third node'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 60
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 14, 29 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'range': new ve.Range( 3, 8 ), 'globalRange': new ve.Range( 14, 19 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 21, 29 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting in the middle of the second node and ending at the end of the third node'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 61
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 14, 30 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'range': new ve.Range( 3, 8 ), 'globalRange': new ve.Range( 14, 19 ) },
|
|
|
|
{ 'node': h, 'globalRange': new ve.Range( 20, 30 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting in the middle of the second node and ending past the end of the third node'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 62
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 19, 21 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'range': new ve.Range( 8, 8 ), 'globalRange': new ve.Range( 19, 19 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 0 ), 'globalRange': new ve.Range( 21, 21 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the end of the second node and ending at the beginning of the third node'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 63
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 19, 27 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'range': new ve.Range( 8, 8 ), 'globalRange': new ve.Range( 19, 19 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 6 ), 'globalRange': new ve.Range( 21, 27 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the end of the second node and ending in the middle of the third node'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 64
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 19, 29 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'range': new ve.Range( 8, 8 ), 'globalRange': new ve.Range( 19, 19 ) },
|
|
|
|
{ 'node': h, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 21, 29 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the end of the second node and ending at the end of the third node'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 65
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 19, 30 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'range': new ve.Range( 8, 8 ), 'globalRange': new ve.Range( 19, 19 ) },
|
|
|
|
{ 'node': h, 'globalRange': new ve.Range( 20, 30 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Range starting at the end of the second node and ending past the end of the third node'
|
|
|
|
},
|
|
|
|
// Tests for childless nodes
|
2011-11-09 23:39:47 +00:00
|
|
|
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 66
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': g,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 1, 3 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'range': new ve.Range( 1, 3 ), 'globalRange': new ve.Range( 1, 3 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Childless node given, range not out of bounds'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 67
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': g,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 0, 8 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': g, 'range': new ve.Range( 0, 8 ), 'globalRange': new ve.Range( 0, 8 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Childless node given, range covers entire node'
|
|
|
|
},
|
|
|
|
// Tests for out-of-bounds cases
|
2011-11-09 23:39:47 +00:00
|
|
|
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 68
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': g,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( -1, 3 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'exception': /^The start offset of the range is negative$/,
|
|
|
|
'desc': 'Childless node given, range start out of bounds'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 69
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': g,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 1, 9 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'exception': /^The end offset of the range is past the end of the node$/,
|
|
|
|
'desc': 'Childless node given, range end out of bounds'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 70
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 31, 35 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'exception': /^The start offset of the range is past the end of the node$/,
|
|
|
|
'desc': 'Node with children given, range start out of bounds'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 71
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 30, 35 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'exception': /^The end offset of the range is past the end of the node$/,
|
|
|
|
'desc': 'Node with children given, range end out of bounds'
|
|
|
|
},
|
|
|
|
// Tests for recursion cases
|
2011-11-09 23:39:47 +00:00
|
|
|
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 72
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': big,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 2, 10 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': big.children[0], 'range': new ve.Range( 1, 3 ), 'globalRange': new ve.Range( 2, 4 ) },
|
|
|
|
{ 'node': big.children[1].children[0].children[0].children[0], 'range': new ve.Range( 0, 1 ), 'globalRange': new ve.Range( 9, 10 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Select from before the b to after the d'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 73
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': big,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 3, 33 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': big.children[0], 'range': new ve.Range( 2, 3 ), 'globalRange': new ve.Range( 3, 4 ) },
|
|
|
|
{ 'node': big.children[1], 'globalRange': new ve.Range( 5, 31 ) },
|
|
|
|
{ 'node': big.children[2], 'range': new ve.Range( 0, 1 ), 'globalRange': new ve.Range( 32, 33 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Select from before the c to after the h'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 74
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': big,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 9, 20 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': big.children[1].children[0].children[0].children[0], 'range': new ve.Range( 0, 1 ), 'globalRange': new ve.Range( 9, 10 ) },
|
|
|
|
{ 'node': big.children[1].children[0].children[0].children[1].children[0], 'globalRange': new ve.Range( 12, 17 ) },
|
|
|
|
{ 'node': big.children[1].children[0].children[0].children[1].children[1].children[0], 'range': new ve.Range( 0, 1 ), 'globalRange': new ve.Range( 19, 20 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Select from before the d to after the f, with recursion'
|
|
|
|
},
|
2011-11-10 13:15:55 +00:00
|
|
|
// Test 75
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': big,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 9, 20 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'shallow': true,
|
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': big.children[1], 'range': new ve.Range( 3, 14 ), 'globalRange': new ve.Range( 9, 20 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Select from before the d to after the f, without recursion'
|
2011-11-17 15:01:47 +00:00
|
|
|
},
|
|
|
|
// Test 76
|
|
|
|
{
|
|
|
|
'node': big,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 3, 9 ),
|
2011-11-17 15:01:47 +00:00
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': big.children[0], 'range': new ve.Range( 2, 3 ), 'globalRange': new ve.Range( 3, 4 ) },
|
|
|
|
{ 'node': big.children[1].children[0].children[0].children[0], 'range': new ve.Range( 0, 0 ), 'globalRange': new ve.Range( 9, 9 ) }
|
2011-11-17 15:01:47 +00:00
|
|
|
],
|
|
|
|
'desc': 'Select from before the c to before the d'
|
|
|
|
},
|
|
|
|
// Test 77
|
|
|
|
{
|
|
|
|
'node': big,
|
2012-02-07 00:12:31 +00:00
|
|
|
'input': new ve.Range( 3, 9 ),
|
2011-11-17 15:01:47 +00:00
|
|
|
'shallow': true,
|
|
|
|
'output': [
|
2012-02-07 00:12:31 +00:00
|
|
|
{ 'node': big.children[0], 'range': new ve.Range( 2, 3 ), 'globalRange': new ve.Range( 3, 4 ) },
|
|
|
|
{ 'node': big.children[1], 'range': new ve.Range( 0, 3 ), 'globalRange': new ve.Range( 6, 9 ) }
|
2011-11-17 15:01:47 +00:00
|
|
|
],
|
|
|
|
'desc': 'Select from before the c to before the d, without recursion'
|
2011-11-02 21:20:55 +00:00
|
|
|
}
|
|
|
|
];
|
2011-11-09 23:39:47 +00:00
|
|
|
|
|
|
|
function compare( a, b ) {
|
|
|
|
if ( $.isArray( a ) && $.isArray( b ) && a.length === b.length ) {
|
|
|
|
for ( var i = 0; i < a.length; i++ ) {
|
|
|
|
if (
|
|
|
|
a[i].node !== b[i].node ||
|
|
|
|
(
|
|
|
|
( typeof a[i].range !== typeof b[i].range ) ||
|
|
|
|
(
|
|
|
|
a[i].range !== undefined &&
|
|
|
|
(
|
|
|
|
a[i].range.start !== b[i].range.start ||
|
|
|
|
a[i].range.end !== b[i].range.end
|
|
|
|
)
|
|
|
|
)
|
2011-11-10 13:15:55 +00:00
|
|
|
) || (
|
|
|
|
( typeof a[i].globalRange !== typeof b[i].globalRange ) ||
|
|
|
|
(
|
|
|
|
a[i].globalRange !== undefined &&
|
|
|
|
(
|
|
|
|
a[i].globalRange.start !== b[i].globalRange.start ||
|
|
|
|
a[i].globalRange.end !== b[i].globalRange.end
|
|
|
|
)
|
|
|
|
)
|
2011-11-09 23:39:47 +00:00
|
|
|
)
|
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2011-11-17 14:21:39 +00:00
|
|
|
return true;
|
2011-11-09 23:39:47 +00:00
|
|
|
}
|
2011-11-17 14:21:39 +00:00
|
|
|
return false;
|
2011-11-09 23:39:47 +00:00
|
|
|
}
|
|
|
|
function select( input, shallow ) {
|
|
|
|
return function() {
|
|
|
|
selectNodesTests[i].node.selectNodes( input, shallow );
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2011-11-02 21:20:55 +00:00
|
|
|
for ( var i = 0; i < selectNodesTests.length; i++ ) {
|
2011-11-04 20:27:23 +00:00
|
|
|
if ( 'output' in selectNodesTests[i] ) {
|
2011-11-09 23:39:47 +00:00
|
|
|
var result = selectNodesTests[i].node.selectNodes(
|
|
|
|
selectNodesTests[i].input, selectNodesTests[i].shallow
|
|
|
|
);
|
|
|
|
ok(
|
|
|
|
compare( result, selectNodesTests[i].output ),
|
|
|
|
selectNodesTests[i].desc +
|
|
|
|
' (from ' + selectNodesTests[i].input.start +
|
|
|
|
' to ' + selectNodesTests[i].input.end + ')'
|
2011-11-04 20:27:23 +00:00
|
|
|
);
|
2011-11-17 14:42:14 +00:00
|
|
|
if ( console && console.log && !compare( result, selectNodesTests[i].output ) ) {
|
2011-11-17 19:23:15 +00:00
|
|
|
console.log( "Test " + (i+1) + " FAILED" );
|
2011-11-17 14:42:14 +00:00
|
|
|
console.log( result );
|
|
|
|
console.log( selectNodesTests[i].output );
|
|
|
|
}
|
2011-11-04 20:27:23 +00:00
|
|
|
} else if ( 'exception' in selectNodesTests[i] ) {
|
|
|
|
raises(
|
|
|
|
function() {
|
2011-11-09 23:39:47 +00:00
|
|
|
selectNodesTests[i].node.selectNodes(
|
|
|
|
selectNodesTests[i].input,
|
|
|
|
selectNodesTests[i].shallow
|
|
|
|
);
|
2011-11-04 20:27:23 +00:00
|
|
|
},
|
|
|
|
selectNodesTests[i].exception,
|
|
|
|
selectNodesTests[i].desc
|
|
|
|
);
|
|
|
|
}
|
2011-11-02 21:20:55 +00:00
|
|
|
}
|
|
|
|
} );
|
2011-11-15 11:12:06 +00:00
|
|
|
|
2012-02-07 00:12:31 +00:00
|
|
|
test( 've.BranchNode.traverseLeafNodes', 11, function() {
|
|
|
|
var root3 = ve.dm.DocumentNode.newFromPlainObject( veTest.obj );
|
2011-11-15 11:12:06 +00:00
|
|
|
|
2011-11-15 14:35:03 +00:00
|
|
|
var tests = [
|
|
|
|
// Test 1 & 2
|
|
|
|
{
|
|
|
|
'node': root3,
|
|
|
|
'output': [
|
|
|
|
root3.children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[0].children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[1].children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[2].children[0],
|
|
|
|
root3.children[2]
|
|
|
|
],
|
|
|
|
'reverse': true,
|
|
|
|
'desc': 'Traversing the entire document returns all leaf nodes'
|
|
|
|
},
|
|
|
|
// Test 3 & 4
|
|
|
|
{
|
|
|
|
'node': root3,
|
|
|
|
'output': [
|
|
|
|
root3.children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[0].children[0]
|
|
|
|
],
|
|
|
|
'reverse': [
|
|
|
|
root3.children[2],
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[2].children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[1].children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[0].children[0]
|
|
|
|
],
|
|
|
|
'callback': function( node ) {
|
|
|
|
if ( node === root3.children[1].children[0].children[0].children[1].children[0].children[0] ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'desc': 'Returning false from the callback stops the traversal'
|
|
|
|
},
|
|
|
|
// Test 5 & 6
|
|
|
|
{
|
|
|
|
'node': root3,
|
|
|
|
'output': [
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[1].children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[2].children[0],
|
|
|
|
root3.children[2]
|
|
|
|
],
|
|
|
|
'reverse': [
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[1].children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[0].children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[0],
|
|
|
|
root3.children[0]
|
|
|
|
],
|
|
|
|
'from': root3.children[1].children[0].children[0].children[1].children[1].children[0],
|
|
|
|
'desc': 'Starting at a leaf node returns that leaf node and everything after it',
|
|
|
|
'reverseDesc': 'Starting at a leaf node returns that leaf node and everything before it (in reverse)'
|
|
|
|
},
|
|
|
|
// Test 7 & 8
|
|
|
|
{
|
|
|
|
'node': root3,
|
|
|
|
'output': [
|
|
|
|
root3.children[1].children[0].children[0].children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[0].children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[1].children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[2].children[0],
|
|
|
|
root3.children[2]
|
|
|
|
],
|
|
|
|
'reverse': [
|
|
|
|
root3.children[0]
|
|
|
|
],
|
|
|
|
'from': root3.children[1],
|
|
|
|
'desc': 'Starting at a non-leaf node returns all leaf nodes inside and after it',
|
|
|
|
'reverseDesc': 'Starting at a non-leaf node returns all leaf nodes before it and none inside (in reverse)'
|
|
|
|
},
|
|
|
|
// Test 9 & 10
|
|
|
|
{
|
|
|
|
'node': root3.children[1],
|
|
|
|
'output': [
|
|
|
|
root3.children[1].children[0].children[0].children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[0].children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[1].children[0],
|
|
|
|
root3.children[1].children[0].children[0].children[1].children[2].children[0]
|
|
|
|
],
|
|
|
|
'reverse': true,
|
|
|
|
'desc': 'Calling traverseLeafNodes() on a non-root node only returns leaf nodes inside that node'
|
|
|
|
},
|
|
|
|
// Test 11
|
|
|
|
{
|
|
|
|
'node': root3.children[1],
|
|
|
|
'from': root3.children[2],
|
|
|
|
'exception': /^from parameter passed to traverseLeafNodes\(\) must be a descendant$/,
|
|
|
|
'desc': 'Passing a sibling for from results in an exception'
|
|
|
|
}
|
2011-11-15 13:50:24 +00:00
|
|
|
];
|
|
|
|
|
2011-11-15 14:35:03 +00:00
|
|
|
for ( var i = 0; i < tests.length; i++ ) {
|
|
|
|
executeTest( tests[i] );
|
|
|
|
if ( tests[i].reverse !== undefined ) {
|
|
|
|
var reversed = {
|
|
|
|
'node': tests[i].node,
|
|
|
|
'from': tests[i].from,
|
|
|
|
'callback': tests[i].callback,
|
|
|
|
'exception': tests[i].exception,
|
|
|
|
'isReversed': true,
|
|
|
|
'desc': tests[i].reverseDesc || tests[i].desc + ' (in reverse)'
|
|
|
|
};
|
|
|
|
if ( tests[i].output !== undefined && tests[i].reverse === true ) {
|
|
|
|
reversed.output = tests[i].output.reverse();
|
|
|
|
} else {
|
|
|
|
reversed.output = tests[i].reverse;
|
|
|
|
}
|
|
|
|
executeTest( reversed );
|
|
|
|
}
|
|
|
|
}
|
2011-11-15 13:50:24 +00:00
|
|
|
|
2011-11-15 14:35:03 +00:00
|
|
|
function executeTest( test ) {
|
|
|
|
var realLeaves = [],
|
|
|
|
callback = function( node ) {
|
|
|
|
var retval;
|
|
|
|
realLeaves.push( node );
|
|
|
|
if ( test.callback ) {
|
|
|
|
retval = test.callback( node );
|
|
|
|
if ( retval !== undefined ) {
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
f = function() {
|
|
|
|
test.node.traverseLeafNodes( callback, test.from, test.isReversed );
|
|
|
|
};
|
|
|
|
if ( test.exception ) {
|
|
|
|
raises( f, test.exception, test.desc );
|
|
|
|
} else {
|
|
|
|
f();
|
2012-02-07 00:12:31 +00:00
|
|
|
ok( ve.compareArrays( realLeaves, test.output ), test.desc );
|
2011-11-15 13:50:24 +00:00
|
|
|
}
|
2011-11-15 14:35:03 +00:00
|
|
|
}
|
2011-11-15 11:12:06 +00:00
|
|
|
} );
|