/**
  * Run tokenizer tests t1.txt ... t$num.txt.
  * Requires t1.ok.txt ... t$num.ok.txt
  *
  * @param any $num (5 = run t1.txt ... t5.txt, 'a.txt' run only this test)
  * @param vector $plugin_list
  */
 public function runTokenizer($num, $plugin_list)
 {
     list($tdir, $rel_tdir) = $this->_test_dir();
     $this->load('Tokenizer.class.php');
     $tok = new Tokenizer(Tokenizer::TOK_DEBUG);
     for ($i = 0; $i < count($plugin_list); $i++) {
         $plugin = 'rkphplib\\' . $plugin_list[$i];
         $this->load($plugin_list[$i] . '.class.php');
         $tok->register(new $plugin());
     }
     $test_files = array();
     if (is_string($num)) {
         $this->_log("runTokenizer: {$rel_tdir}/{$num}", 11);
         array_push($test_files, $tdir . '/' . $num);
     } else {
         if ($num > 1) {
             $this->_log("runTokenizer: {$rel_tdir}/t1.txt ... {$rel_tdir}/t{$num}.txt", 11);
         } else {
             $this->_log("runTokenizer: {$rel_tdir}/t{$num}.txt", 11);
         }
         for ($i = 1; $i <= $num; $i++) {
             array_push($test_files, $tdir . '/t' . $i . '.txt');
         }
     }
     $i = 0;
     foreach ($test_files as $f_txt) {
         $f_out = str_replace('.txt', '.out.txt', $f_txt);
         $f_ok = str_replace('.txt', '.ok.txt', $f_txt);
         $i++;
         $tok->setText(File::load($f_txt));
         $ok = File::load($f_ok);
         $out = $tok->toString();
         $this->_tc['num']++;
         $this->_log("Test {$i} ... ", 0);
         if ($out != $ok) {
             if (mb_strlen($out) > 40 || strpos($out, "\n") !== false) {
                 $this->_log("ERROR! (see {$f_out})");
                 File::save($f_out, $out);
             } else {
                 $this->_log("{$out} != {$ok} - ERROR!");
             }
             $this->_tc['error']++;
         } else {
             $this->_tc['ok']++;
             $this->_log("ok");
         }
     }
 }