2011-11-02 21:20:55 +00:00
|
|
|
module( 'es/bases' );
|
|
|
|
|
2011-11-04 18:08:51 +00:00
|
|
|
/* Stubs */
|
|
|
|
|
2011-11-04 17:54:02 +00:00
|
|
|
function DocumentBranchNodeStub( items, name, size ) {
|
2011-11-03 21:48:40 +00:00
|
|
|
// Inheritance
|
|
|
|
es.DocumentBranchNode.call( this, items );
|
|
|
|
|
|
|
|
// Properties
|
2011-11-02 21:20:55 +00:00
|
|
|
this.name = name;
|
|
|
|
this.size = size;
|
|
|
|
}
|
|
|
|
|
2011-11-04 17:54:02 +00:00
|
|
|
DocumentBranchNodeStub.prototype.getContentLength = function() {
|
2011-11-02 21:20:55 +00:00
|
|
|
return this.size;
|
|
|
|
};
|
|
|
|
|
2011-11-04 17:54:02 +00:00
|
|
|
DocumentBranchNodeStub.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;
|
|
|
|
};
|
|
|
|
|
2011-11-04 17:54:02 +00:00
|
|
|
es.extendClass( DocumentBranchNodeStub, es.DocumentBranchNode );
|
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
|
|
|
|
2011-11-04 18:08:51 +00:00
|
|
|
test( 'es.DocumentBranchNodeStub.getElementLength', 1, function() {
|
|
|
|
// Test 1
|
2011-11-02 21:20:55 +00:00
|
|
|
strictEqual(
|
2011-11-04 17:54:02 +00:00
|
|
|
( new DocumentBranchNodeStub( [], 'a', 0 ) ).getElementLength(),
|
2011-11-02 21:20:55 +00:00
|
|
|
2,
|
2011-11-04 17:54:02 +00:00
|
|
|
'DocumentBranchNodeStub.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
|
|
|
|
var a = new DocumentBranchNodeStub( [], 'a', 0 ),
|
|
|
|
b = new DocumentBranchNodeStub( [], 'b', 1 ),
|
|
|
|
c = new DocumentBranchNodeStub( [], 'c', 2 ),
|
|
|
|
d = new DocumentBranchNodeStub( [], 'd', 3 ),
|
|
|
|
e = new DocumentBranchNodeStub( [], 'e', 4 ),
|
|
|
|
root1 = new DocumentBranchNodeStub( [a, b, c, d, e], 'root1', 20 );
|
2011-11-02 21:20:55 +00:00
|
|
|
|
2011-11-04 18:08:51 +00:00
|
|
|
test( 'es.DocumentBranchNode.getRangeFromNode', 6, function() {
|
|
|
|
// Tests 1 .. 6
|
2011-11-02 21:20:55 +00:00
|
|
|
var getRangeFromNodeTests = [
|
|
|
|
{ 'input': a, 'output': new es.Range( 0, 2 ) },
|
|
|
|
{ 'input': b, 'output': new es.Range( 2, 5 ) },
|
|
|
|
{ 'input': c, 'output': new es.Range( 5, 9 ) },
|
|
|
|
{ 'input': d, 'output': new es.Range( 9, 14 ) },
|
|
|
|
{ 'input': e, 'output': new es.Range( 14, 20 ) },
|
|
|
|
{ '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
|
|
|
|
2011-11-09 23:39:47 +00:00
|
|
|
test( 'es.DocumentBranchNode.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
|
|
|
|
2011-11-04 18:08:51 +00:00
|
|
|
test( 'es.DocumentBranchNode.getOffsetFromNode', 6, function() {
|
|
|
|
// 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'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2011-11-04 20:27:23 +00:00
|
|
|
test( 'es.DocumentBranchNode.selectNodes', 75, 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
|
2011-11-04 17:54:02 +00:00
|
|
|
var f = new DocumentBranchNodeStub( [], 'f', 8 ),
|
|
|
|
g = new DocumentBranchNodeStub( [], 'g', 8 ),
|
|
|
|
h = new DocumentBranchNodeStub( [], 'h', 8 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
root2 = new DocumentBranchNodeStub( [f, g, h], 'root2', 30 ),
|
|
|
|
big = es.DocumentModel.newFromPlainObject( esTest.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,
|
|
|
|
'input': new es.Range( 0, 0 ),
|
|
|
|
'output': [],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 0, 1 ),
|
|
|
|
'output': [{ 'node': f, 'range': new es.Range( 0, 0 ) }],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 10, 15 ),
|
|
|
|
'output': [{ 'node': g, 'range': new es.Range( 0, 4 ) }],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 20, 29 ),
|
|
|
|
'output': [{ 'node': h, 'range': new es.Range( 0, 8 ) }],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 0, 10 ),
|
|
|
|
'output': [{ 'node': f } ],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 11, 11 ),
|
|
|
|
'output': [{ 'node': g, 'range': new es.Range( 0, 0 ) }],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 21, 26 ),
|
|
|
|
'output': [{ 'node': h, 'range': new es.Range( 0, 5 ) }],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 1, 9 ),
|
|
|
|
'output': [{ 'node': f, 'range': new es.Range( 0, 8 ) }],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 11, 20 ),
|
|
|
|
'output': [{ 'node': g, 'range': new es.Range( 0, 8 ) }],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 22, 22 ),
|
|
|
|
'output': [{ 'node': h, 'range': new es.Range( 1, 1 ) }],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 2, 7 ),
|
|
|
|
'output': [{ 'node': f, 'range': new es.Range( 1, 6 ) }],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 13, 19 ),
|
|
|
|
'output': [{ 'node': g, 'range': new es.Range( 2, 8 ) }],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 24, 30 ),
|
|
|
|
'output': [{ 'node': h, 'range': new es.Range( 3, 8 ) }],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 9, 9 ),
|
|
|
|
'output': [{ 'node': f, 'range': new es.Range( 8, 8 ) }],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 19, 20 ),
|
|
|
|
'output': [{ 'node': g, 'range': new es.Range( 8, 8 ) }],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 30, 30 ),
|
|
|
|
'output': [],
|
|
|
|
'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,
|
2011-11-04 20:27:23 +00:00
|
|
|
'input': new es.Range( 20, 20 ),
|
|
|
|
'output': [],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 0, 11 ),
|
2011-11-02 21:20:55 +00:00
|
|
|
'output': [
|
2011-11-04 20:27:23 +00:00
|
|
|
{ 'node': f },
|
|
|
|
{ 'node': g, 'range': new es.Range( 0, 0 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 0, 14 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f },
|
|
|
|
{ 'node': g, 'range': new es.Range( 0, 3 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 0, 19 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f },
|
|
|
|
{ 'node': g, 'range': new es.Range( 0, 8 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 0, 20 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f },
|
|
|
|
{ 'node': g }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 0, 21 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f },
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 0 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 0, 27 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f },
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 6 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 0, 29 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f },
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 8 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 0, 30 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f },
|
2011-11-02 21:20:55 +00:00
|
|
|
{ 'node': g },
|
2011-11-04 20:27:23 +00:00
|
|
|
{ 'node': h }
|
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,
|
|
|
|
'input': new es.Range( 1, 11 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 0, 8 ) },
|
|
|
|
{ 'node': g, 'range': new es.Range( 0, 0 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 1, 14 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 0, 8 ) },
|
|
|
|
{ 'node': g, 'range': new es.Range( 0, 3 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 1, 19 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 0, 8 ) },
|
|
|
|
{ 'node': g, 'range': new es.Range( 0, 8 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 1, 20 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 0, 8 ) },
|
|
|
|
{ 'node': g }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 1, 21 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 0, 8 ) },
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 0 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 1, 27 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 0, 8 ) },
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 6 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 1, 29 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 0, 8 ) },
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 8 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 1, 30 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 0, 8 ) },
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 5, 11 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 4, 8 ) },
|
|
|
|
{ 'node': g, 'range': new es.Range( 0, 0 ) }
|
|
|
|
],
|
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,
|
2011-11-04 20:27:23 +00:00
|
|
|
'input': new es.Range( 5, 14 ),
|
2011-11-02 21:20:55 +00:00
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 4, 8 ) },
|
2011-11-04 20:27:23 +00:00
|
|
|
{ 'node': g, 'range': new es.Range( 0, 3 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 5, 19 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 4, 8 ) },
|
|
|
|
{ 'node': g, 'range': new es.Range( 0, 8 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 5, 20 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 4, 8 ) },
|
|
|
|
{ 'node': g }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 5, 21 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 4, 8 ) },
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 0 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 5, 27 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 4, 8 ) },
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 6 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 5, 29 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 4, 8 ) },
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 8 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 5, 30 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 4, 8 ) },
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 9, 11 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 8, 8 ) },
|
|
|
|
{ 'node': g, 'range': new es.Range( 0, 0 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 9, 14 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 8, 8 ) },
|
|
|
|
{ 'node': g, 'range': new es.Range( 0, 3 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 9, 19 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 8, 8 ) },
|
|
|
|
{ 'node': g, 'range': new es.Range( 0, 8 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 9, 20 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 8, 8 ) },
|
|
|
|
{ 'node': g }
|
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,
|
2011-11-04 20:27:23 +00:00
|
|
|
'input': new es.Range( 9, 21 ),
|
2011-11-02 21:20:55 +00:00
|
|
|
'output': [
|
2011-11-04 20:27:23 +00:00
|
|
|
{ 'node': f, 'range': new es.Range( 8, 8 ) },
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 0 ) }
|
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,
|
2011-11-04 20:27:23 +00:00
|
|
|
'input': new es.Range( 9, 27 ),
|
2011-11-02 21:20:55 +00:00
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 8, 8 ) },
|
2011-11-04 20:27:23 +00:00
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 6 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 9, 29 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 8, 8 ) },
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 8 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 9, 30 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': f, 'range': new es.Range( 8, 8 ) },
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 10, 21 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 0 ) }
|
|
|
|
],
|
|
|
|
'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,
|
|
|
|
'input': new es.Range( 10, 27 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 6 ) }
|
|
|
|
],
|
|
|
|
'desc': 'Range starting between the first and the second node and ending in the middle of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 56
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
|
|
|
'input': new es.Range( 10, 29 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 8 ) }
|
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-09 23:39:47 +00:00
|
|
|
// Test 57
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
|
|
|
'input': new es.Range( 10, 30 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g },
|
|
|
|
{ 'node': h }
|
|
|
|
],
|
|
|
|
'desc': 'Range starting between the first and the second node and ending past the end of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 58
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
|
|
|
'input': new es.Range( 11, 21 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g, 'range': new es.Range( 0, 8 ) },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 0 ) }
|
|
|
|
],
|
|
|
|
'desc': 'Range starting at the beginning of the second node and ending at the beginning of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 59
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
|
|
|
'input': new es.Range( 11, 27 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g, 'range': new es.Range( 0, 8 ) },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 6 ) }
|
|
|
|
],
|
|
|
|
'desc': 'Range starting at the beginning of the second node and ending in the middle of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 60
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
|
|
|
'input': new es.Range( 11, 29 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g, 'range': new es.Range( 0, 8 ) },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 8 ) }
|
|
|
|
],
|
|
|
|
'desc': 'Range starting at the beginning of the second node and ending at the end of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 61
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
|
|
|
'input': new es.Range( 11, 30 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g, 'range': new es.Range( 0, 8 ) },
|
|
|
|
{ 'node': h }
|
|
|
|
],
|
|
|
|
'desc': 'Range starting at the beginning of the second node and ending past the end of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 62
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
|
|
|
'input': new es.Range( 14, 21 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g, 'range': new es.Range( 3, 8 ) },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 0 ) }
|
|
|
|
],
|
|
|
|
'desc': 'Range starting in the middle of the second node and ending at the beginning of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 63
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
|
|
|
'input': new es.Range( 14, 27 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g, 'range': new es.Range( 3, 8 ) },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 6 ) }
|
|
|
|
],
|
|
|
|
'desc': 'Range starting in the middle of the second node and ending in the middle of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 64
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
|
|
|
'input': new es.Range( 14, 29 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g, 'range': new es.Range( 3, 8 ) },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 8 ) }
|
|
|
|
],
|
|
|
|
'desc': 'Range starting in the middle of the second node and ending at the end of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 65
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
|
|
|
'input': new es.Range( 14, 30 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g, 'range': new es.Range( 3, 8 ) },
|
|
|
|
{ 'node': h }
|
|
|
|
],
|
|
|
|
'desc': 'Range starting in the middle of the second node and ending past the end of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 66
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
|
|
|
'input': new es.Range( 19, 21 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g, 'range': new es.Range( 8, 8 ) },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 0 ) }
|
|
|
|
],
|
|
|
|
'desc': 'Range starting at the end of the second node and ending at the beginning of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 67
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
|
|
|
'input': new es.Range( 19, 27 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g, 'range': new es.Range( 8, 8 ) },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 6 ) }
|
|
|
|
],
|
|
|
|
'desc': 'Range starting at the end of the second node and ending in the middle of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 68
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
|
|
|
'input': new es.Range( 19, 29 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g, 'range': new es.Range( 8, 8 ) },
|
|
|
|
{ 'node': h, 'range': new es.Range( 0, 8 ) }
|
|
|
|
],
|
|
|
|
'desc': 'Range starting at the end of the second node and ending at the end of the third node'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 69
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
|
|
|
'input': new es.Range( 19, 30 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g, 'range': new es.Range( 8, 8 ) },
|
|
|
|
{ 'node': h }
|
|
|
|
],
|
|
|
|
'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
|
|
|
|
|
|
|
// Test 70
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': g,
|
|
|
|
'input': new es.Range( 1, 3 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g, 'range': new es.Range( 1, 3 ) }
|
|
|
|
],
|
|
|
|
'desc': 'Childless node given, range not out of bounds'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 72
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': g,
|
|
|
|
'input': new es.Range( 0, 8 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': g, 'range': new es.Range( 0, 8 ) }
|
|
|
|
],
|
|
|
|
'desc': 'Childless node given, range covers entire node'
|
|
|
|
},
|
|
|
|
// Tests for out-of-bounds cases
|
2011-11-09 23:39:47 +00:00
|
|
|
|
|
|
|
// Test 73
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': g,
|
|
|
|
'input': new es.Range( -1, 3 ),
|
|
|
|
'exception': /^The start offset of the range is negative$/,
|
|
|
|
'desc': 'Childless node given, range start out of bounds'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 74
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': g,
|
|
|
|
'input': new es.Range( 1, 9 ),
|
|
|
|
'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-09 23:39:47 +00:00
|
|
|
// Test 75
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
|
|
|
'input': new es.Range( 31, 35 ),
|
|
|
|
'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-09 23:39:47 +00:00
|
|
|
// Test 76
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': root2,
|
|
|
|
'input': new es.Range( 30, 35 ),
|
|
|
|
'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
|
|
|
|
|
|
|
// Test 77
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': big,
|
|
|
|
'input': new es.Range( 2, 10 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': big.children[0], 'range': new es.Range( 1, 3 ) },
|
|
|
|
{ 'node': big.children[1], 'range': new es.Range( 0, 4 ) }
|
|
|
|
],
|
|
|
|
'desc': 'Select from before the b to after the d'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 78
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': big,
|
2011-11-09 23:39:47 +00:00
|
|
|
'input': new es.Range( 3, 29 ),
|
2011-11-04 20:27:23 +00:00
|
|
|
'output': [
|
2011-11-09 23:39:47 +00:00
|
|
|
{ 'node': big.children[0], 'range': new es.Range( 2, 8 ) },
|
2011-11-04 20:27:23 +00:00
|
|
|
{ 'node': big.children[1] },
|
2011-11-09 23:39:47 +00:00
|
|
|
{ 'node': big.children[2], 'range': new es.Range( 0, 8 ) }
|
2011-11-04 20:27:23 +00:00
|
|
|
],
|
|
|
|
'desc': 'Select from before the c to after the h'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 79
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': big,
|
|
|
|
'input': new es.Range( 9, 17 ),
|
|
|
|
'output': [
|
|
|
|
{ 'node': big.children[1].children[0].children[0].children[0], 'range': new es.Range( 0, 1 ) },
|
|
|
|
{ 'node': big.children[1].children[0].children[0].children[1], 'range': new es.Range( 0, 5 ) }
|
|
|
|
],
|
|
|
|
'desc': 'Select from before the d to after the f, with recursion'
|
|
|
|
},
|
2011-11-09 23:39:47 +00:00
|
|
|
// Test 80
|
2011-11-04 20:27:23 +00:00
|
|
|
{
|
|
|
|
'node': big,
|
|
|
|
'input': new es.Range( 9, 17 ),
|
|
|
|
'shallow': true,
|
|
|
|
'output': [
|
|
|
|
{ 'node': big.children[1], 'range': new es.Range( 3, 11 ) }
|
|
|
|
],
|
|
|
|
'desc': 'Select from before the d to after the f, 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
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
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
|
|
|
);
|
|
|
|
} 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
|
|
|
}
|
|
|
|
} );
|