File indexing completed on 2024-05-19 05:06:11

0001 // sectioning tests
0002 //
0003 // Needs original 'scripting-test.tex' as current tex file opened in Kile.
0004 // Kile should be started from the command line to view the results.
0005 
0006 var arr = new Array(
0007         new Array(8,  "\\section*{Test 1}"),
0008         new Array(12, "\\section*{Test 2}"),
0009         new Array(17, "\\section*{Test 3}"),
0010         new Array(21, "\\section*{Test 4}"),
0011         new Array(27, "\\section*{Test 5}")
0012 );
0013 
0014 var len = arr.length;
0015 view.setCursorPosition(0,0);
0016 
0017 print();
0018 print( "Test: sectioning...");
0019 for ( var i=0; i<len; ++i ) {
0020         sectioningTest(1,arr[i]);
0021 }
0022 print("part 1 finished");
0023 
0024 view.setCursorPosition(document.lines()-1,0);
0025 for ( var i=len-1; i>=0; --i ) {
0026         sectioningTest(-1,arr[i]);
0027 }
0028 print("part 2 finished");
0029 print();
0030 
0031 function sectioningTest(direction,arr)
0032 {
0033         if ( direction == 1 )
0034                 document.gotoNextSectioning();
0035         else
0036                 document.gotoPrevSectioning();
0037 
0038         var cursor = view.cursorPosition();
0039         var line = cursor.line;
0040         var text = document.line( cursor.line );
0041 
0042         var lineExpected = arr[0];
0043         var textExpected = arr[1];
0044 
0045         if ( line != lineExpected ) {
0046                 print ("line: " + line + "  expected: "+lineExpected);
0047         }
0048         if ( text != textExpected ) {
0049                 print ("text: " + text + "  expected: "+textExpected);
0050         }
0051 }
0052