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

0001 // word/latexCommand 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 arr1 = new Array(
0007         5,0,  "",
0008         5,1,  "usepackage",
0009         5,7,  "usepackage",
0010         5,11, "usepackage",
0011         5,12, "amsmath",
0012         5,15, "amsmath" ,
0013         5,19, "amsmath" ,
0014         5,20, "",
0015         8,0,  "",
0016         8,1,  "section",
0017         8,8,  "section",
0018         8,10, "Test",
0019         8,14, "Test"
0020 );
0021 
0022 var arr2 = new Array(
0023         5,0,  "\\usepackage",
0024         5,1,  "\\usepackage",
0025         5,7,  "\\usepackage",
0026         5,11, "\\usepackage",
0027         5,12, "amsmath",
0028         5,15, "amsmath" ,
0029         5,19, "amsmath" ,
0030         5,20, "",
0031         8,0,  "\\section*",
0032         8,1,  "\\section*",
0033         8,8,  "\\section*",
0034         8,10, "Test",
0035         8,14, "Test"
0036 );
0037 
0038 var len = arr1.length / 3;
0039 
0040 // ------ word wordAt ------
0041 print();
0042 print( "Test: wordTest1...");
0043 for ( var i=0; i<len; ++i ) {
0044         wordTest1(arr1[3*i],arr1[3*i+1],arr1[3*i+2]);
0045 }
0046 print("finished");
0047 print();
0048 
0049 print( "Test: wordTest2...");
0050 for ( var i=0; i<len; ++i ) {
0051         wordTest2(arr1[3*i],arr1[3*i+1],arr1[3*i+2]);
0052 }
0053 print("finished");
0054 print();
0055 
0056 print( "Test: wordAt...");
0057 for ( var i=0; i<len; ++i ) {
0058         wordAtTest(arr1[3*i],arr1[3*i+1],arr1[3*i+2]);
0059 }
0060 print("finished");
0061 print();
0062 
0063 
0064 // ------ latexCommand latexCommandAt ------
0065 
0066 print( "Test: latexCommand1...");
0067 for ( var i=0; i<len; ++i ) {
0068         latexCommandTest1(arr2[3*i],arr2[3*i+1],arr2[3*i+2]);
0069 }
0070 print("finished");
0071 print();
0072 
0073 print( "Test: latexCommand2...");
0074 for ( var i=0; i<len; ++i ) {
0075         latexCommandTest2(arr2[3*i],arr2[3*i+1],arr2[3*i+2]);
0076 }
0077 print("finished");
0078 print();
0079 
0080 print( "Test: latexCommandAt...");
0081 for ( var i=0; i<len; ++i ) {
0082         latexCommandAtTest(arr2[3*i],arr2[3*i+1],arr2[3*i+2]);
0083 }
0084 print("finished");
0085 print();
0086 
0087 
0088 function wordTest1(line,col,expected)
0089 {
0090         view.setCursorPosition(line,col);
0091         var x = document.word();
0092         if ( x != expected ) {
0093                 print ("wordAt " + line + "/" + col + ": " + x + "  expected: "+expected);
0094         }
0095 }
0096 
0097 function wordTest2(line,col,expected)
0098 {
0099         var cursor = new Cursor(line,col);
0100         view.setCursorPosition(cursor);
0101         var x = document.word();
0102         if ( x != expected ) {
0103                 print ("wordAt " + cursor.toString() + ": " + x + "  expected: "+expected);
0104         }
0105 }
0106 
0107 function wordAtTest(line,col,expected)
0108 {
0109         var x = document.wordAt(line,col);
0110         if ( x != expected ) {
0111                 print ("wordAt: " + x + "  expected: "+expected);
0112         }
0113 }
0114 
0115 function latexCommandTest1(line,col,expected)
0116 {
0117         view.setCursorPosition(line,col);
0118         var x = document.latexCommand();
0119         if ( x != expected ) {
0120                 print ("latexCommand " + line + "/" + col + ": " + x + "  expected: "+expected);
0121         }
0122 }
0123 
0124 function latexCommandTest2(line,col,expected)
0125 {
0126         var cursor = new Cursor(line,col);
0127         view.setCursorPosition(cursor);
0128         var x = document.latexCommand();
0129         if ( x != expected ) {
0130                 print ("latexCommand " + cursor.toString() + ": " + x + "  expected: "+expected);
0131         }
0132 }
0133 
0134 function latexCommandAtTest(line,col,expected)
0135 {
0136         var x = document.latexCommandAt(line,col);
0137         if ( x != expected ) {
0138                 print ("latexCommandAt: " + x + "  expected: "+expected);
0139         }
0140 }