File indexing completed on 2024-05-12 16:41:19

0001 // paragraph 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( 0,2,5,7,11,16,20,26,35 );
0007 
0008 var len = arr.length;
0009 view.setCursorPosition(0,0);
0010 
0011 print();
0012 print( "Test: paragraph...");
0013 for ( var i=0; i<len-1; ++i ) {
0014         paragraphTest(1,arr[i+1]);
0015 }
0016 print("part 1 finished");
0017 
0018 view.setCursorPosition(document.lines(),0);
0019 for ( var i=len-1; i>=1; --i ) {
0020         paragraphTest(-1,arr[i-1]);
0021 }
0022 print("part 2 finished");
0023 print();
0024 
0025 function paragraphTest(direction,expected)
0026 {
0027         if ( direction == 1 )
0028                 document.gotoNextParagraph();
0029         else
0030                 document.gotoPrevParagraph();
0031 
0032         var cursor = view.cursorPosition();
0033         var line = cursor.line;
0034         var text = document.line( cursor.line );
0035 
0036         if ( line != expected ) {
0037                 print ("line: " + line + "  expected: "+expected);
0038         }
0039 }
0040