[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/_test/cases/lib/exe/ -> js_js_compress.test.php (source)

   1  <?php
   2  
   3  require_once  DOKU_INC.'lib/exe/js.php';
   4  
   5  
   6  class js_js_compress_test extends UnitTestCase {
   7  
   8      function test_mlcom1(){
   9          $text = '/**
  10                    * A multi
  11                    * line *test*
  12                    * check
  13                    */';
  14          $this->assertEqual(js_compress($text), '');
  15      }
  16  
  17      function test_mlcom2(){
  18          $text = 'var foo=6;/* another comment */';
  19          $this->assertEqual(js_compress($text), 'var foo=6;');
  20      }
  21  
  22      function test_mlcomcond(){
  23          $text = '/*@if (@_win32)';
  24          $this->assertEqual(js_compress($text), '/*@if(@_win32)');
  25      }
  26  
  27      function test_slcom1(){
  28          $text = '// an comment';
  29          $this->assertEqual(js_compress($text), '');
  30      }
  31  
  32      function test_slcom2(){
  33          $text = 'var foo=6;// another comment ';
  34          $this->assertEqual(js_compress($text), 'var foo=6;');
  35      }
  36  
  37      function test_slcom3(){
  38          $text = 'var foo=6;// another comment / or something with // comments ';
  39          $this->assertEqual(js_compress($text), 'var foo=6;');
  40      }
  41  
  42      function test_regex1(){
  43          $text = 'foo.split( /[a-Z\/]*/ );';
  44          $this->assertEqual(js_compress($text), 'foo.split(/[a-Z\/]*/);');
  45      }
  46  
  47      function test_dquot1(){
  48          $text = 'var foo="Now what \\" \'do we//get /*here*/ ?";';
  49          $this->assertEqual(js_compress($text), $text);
  50      }
  51  
  52      function test_dquot2(){
  53          $text = 'var foo="Now what \\\\\\" \'do we//get /*here*/ ?";';
  54          $this->assertEqual(js_compress($text), $text);
  55      }
  56  
  57      function test_dquotrunaway(){
  58          $text = 'var foo="Now where does it end';
  59          $this->assertEqual(js_compress($text), "$text");
  60      }
  61  
  62      function test_squot1(){
  63          $text = "var foo='Now what \\' \"do we//get /*here*/ ?';";
  64          $this->assertEqual(js_compress($text), $text);
  65      }
  66  
  67      function test_squotrunaway(){
  68          $text = "var foo='Now where does it end";
  69          $this->assertEqual(js_compress($text), "$text");
  70      }
  71  
  72      function test_nl1(){
  73          $text = "var foo=6;\nvar baz=7;";
  74          $this->assertEqual(js_compress($text), 'var foo=6;var baz=7;');
  75      }
  76  
  77      function test_lws1(){
  78          $text = "  \t  var foo=6;";
  79          $this->assertEqual(js_compress($text), 'var foo=6;');
  80      }
  81  
  82      function test_tws1(){
  83          $text = "var foo=6;  \t  ";
  84          $this->assertEqual(js_compress($text), 'var foo=6;');
  85      }
  86  
  87      function test_shortcond(){
  88          $text = "var foo = (baz) ? 'bar' : 'bla';";
  89          $this->assertEqual(js_compress($text), "var foo=(baz)?'bar':'bla';");
  90  
  91      }
  92  
  93      /**
  94       * Test the files provided with the original JsStrip
  95       */
  96      function test_original(){
  97          $files = glob(dirname(__FILE__).'/js_js_compress/test-*-in.js');
  98  
  99          foreach($files as $file){
 100              $info = "Using file $file";
 101              $this->signal('failinfo',$info);
 102              $this->assertEqual(js_compress(file_get_contents($file)),
 103                                 file_get_contents(substr($file,0,-5).'out.js'));
 104          };
 105      }
 106  }
 107  
 108  //Setup VIM: ex: et ts=4 enc=utf-8 :


Generated: Wed Dec 3 01:30:02 2008 Cross-referenced by PHPXref 0.7