summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorGerry Weißbach <gerry.w@gammaproduction.de>2014-12-22 10:40:15 +0100
committerGerry Weißbach <gerry.w@gammaproduction.de>2014-12-22 10:40:15 +0100
commitfc30ac3acbd4e17e25955ccdd0c5539ee2c9beca (patch)
tree3d287ae466500a6072b84d14ff4911fa936d1479 /_test
parentde4634ec87b1a277c1686990d993dafc43db05ed (diff)
parent8da2ebf4f4261eb8f54df5704b5d9af283b5402d (diff)
downloadrpg-fc30ac3acbd4e17e25955ccdd0c5539ee2c9beca.tar.gz
rpg-fc30ac3acbd4e17e25955ccdd0c5539ee2c9beca.tar.bz2
Merge branch 'master' into new_css.php
Diffstat (limited to '_test')
-rw-r--r--_test/core/TestRequest.php2
-rw-r--r--_test/data/media/wiki/kind_zu_katze.ogvbin0 -> 45883 bytes
-rw-r--r--_test/data/media/wiki/kind_zu_katze.pngbin0 -> 970 bytes
-rw-r--r--_test/data/media/wiki/kind_zu_katze.webmbin0 -> 101529 bytes
-rw-r--r--_test/tests/inc/changelog_getlastrevisionat.test.php127
-rw-r--r--_test/tests/inc/common_ml.test.php11
-rw-r--r--_test/tests/inc/common_wl.test.php11
-rw-r--r--_test/tests/inc/init_checkssl.test.php81
-rw-r--r--_test/tests/inc/input.test.php50
-rw-r--r--_test/tests/inc/parser/parser_footnote.test.php2
-rw-r--r--_test/tests/inc/parser/parser_lists.test.php20
-rw-r--r--_test/tests/inc/parser/parser_media.test.php103
-rw-r--r--_test/tests/lib/exe/js_js_compress.test.php78
13 files changed, 472 insertions, 13 deletions
diff --git a/_test/core/TestRequest.php b/_test/core/TestRequest.php
index 060e37d28..dad2060e5 100644
--- a/_test/core/TestRequest.php
+++ b/_test/core/TestRequest.php
@@ -45,8 +45,6 @@ class TestRequest {
*/
public function execute($uri='/doku.php') {
global $INPUT;
- global $ID;
- global $INFO;
// save old environment
$server = $_SERVER;
diff --git a/_test/data/media/wiki/kind_zu_katze.ogv b/_test/data/media/wiki/kind_zu_katze.ogv
new file mode 100644
index 000000000..1ad3732dc
--- /dev/null
+++ b/_test/data/media/wiki/kind_zu_katze.ogv
Binary files differ
diff --git a/_test/data/media/wiki/kind_zu_katze.png b/_test/data/media/wiki/kind_zu_katze.png
new file mode 100644
index 000000000..a5c151e3f
--- /dev/null
+++ b/_test/data/media/wiki/kind_zu_katze.png
Binary files differ
diff --git a/_test/data/media/wiki/kind_zu_katze.webm b/_test/data/media/wiki/kind_zu_katze.webm
new file mode 100644
index 000000000..2973ff833
--- /dev/null
+++ b/_test/data/media/wiki/kind_zu_katze.webm
Binary files differ
diff --git a/_test/tests/inc/changelog_getlastrevisionat.test.php b/_test/tests/inc/changelog_getlastrevisionat.test.php
new file mode 100644
index 000000000..84b185ce8
--- /dev/null
+++ b/_test/tests/inc/changelog_getlastrevisionat.test.php
@@ -0,0 +1,127 @@
+<?php
+
+/**
+ * Tests for requesting revisioninfo of a revision of a page with getRevisionInfo()
+ *
+ * This class uses the files:
+ * - data/pages/mailinglist.txt
+ * - data/meta/mailinglist.changes
+ */
+class changelog_getlastrevisionat_test extends DokuWikiTest {
+
+ private $pageid = 'mailinglist';
+
+ function setup() {
+ parent::setup();
+ global $cache_revinfo;
+ $cache =& $cache_revinfo;
+ if(isset($cache['nonexist'])) {
+ unset($cache['nonexist']);
+ }
+ if(isset($cache['mailinglist'])) {
+ unset($cache['mailinglist']);
+ }
+ }
+
+
+ /**
+ * no nonexist.changes meta file available
+ */
+ function test_changemetadatanotexists() {
+ $rev = 1362525899;
+ $id = 'nonexist';
+ $revsexpected = false;
+
+ $pagelog = new PageChangeLog($id, $chunk_size = 8192);
+ $revs = $pagelog->getLastRevisionAt($rev);
+ $this->assertEquals($revsexpected, $revs);
+ }
+
+ /**
+ * start at exact current revision of mailinglist page
+ *
+ */
+ function test_startatexactcurrentrev() {
+ $rev = 1385051947;
+ $revsexpected = '';
+
+ //set a known timestamp
+ touch(wikiFN($this->pageid), $rev);
+
+ $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192);
+ $revs = $pagelog->getLastRevisionAt($rev);
+ $this->assertEquals($revsexpected, $revs);
+
+ }
+
+ /**
+ * test a future revision
+ *
+ */
+ function test_futurerev() {
+ $rev = 1385051947;
+ $revsexpected = '';
+
+ //set a known timestamp
+ touch(wikiFN($this->pageid), $rev);
+
+ $rev +=1;
+
+ $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192);
+ $revs = $pagelog->getLastRevisionAt($rev);
+ $this->assertEquals($revsexpected, $revs);
+
+ }
+
+ /**
+ * start at exact last revision of mailinglist page
+ *
+ */
+ function test_exactlastrev() {
+ $rev = 1360110636;
+ $revsexpected = 1360110636;
+
+ $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192);
+ $revs = $pagelog->getLastRevisionAt($rev);
+ $this->assertEquals($revsexpected, $revs);
+ }
+
+
+ /**
+ * Request not existing revision
+ *
+ */
+ function test_olderrev() {
+ $rev = 1;
+ $revexpected = false;
+
+ $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192);
+ $revfound = $pagelog->getLastRevisionAt($rev);
+ $this->assertEquals($revexpected, $revfound);
+ }
+
+ /**
+ * Start at non existing revision somewhere between existing revisions
+ */
+ function test_notexistingrev() {
+ $rev = 1362525890;
+ $revexpected = 1362525359;
+
+ $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192);
+ $revfound = $pagelog->getLastRevisionAt($rev);
+ $this->assertEquals($revexpected, $revfound);
+ }
+
+ /**
+ * request nonexisting page
+ *
+ */
+ function test_notexistingpage() {
+ $rev = 1385051947;
+ $currentexpected = false;
+
+ $pagelog = new PageChangeLog('nonexistingpage', $chunk_size = 8192);
+ $current = $pagelog->getLastRevisionAt($rev);
+ $this->assertEquals($currentexpected, $current);
+ }
+} \ No newline at end of file
diff --git a/_test/tests/inc/common_ml.test.php b/_test/tests/inc/common_ml.test.php
index 415c0a88d..027dcaef2 100644
--- a/_test/tests/inc/common_ml.test.php
+++ b/_test/tests/inc/common_ml.test.php
@@ -146,4 +146,15 @@ class common_ml_test extends DokuWikiTest {
$this->assertEquals($expect, ml($id, $args));
}
+
+ function test_ml_empty_rev() {
+ global $conf;
+ $conf['useslash'] = 0;
+ $conf['userewrite'] = 0;
+
+ $args = array('a' => 'b', 'c' => 'd', 'rev' => '');
+
+ $expect = DOKU_BASE . $this->script . '?a=b&amp;c=d&amp;media=some:img.jpg';
+ $this->assertEquals($expect, ml('some:img.jpg', $args));
+ }
}
diff --git a/_test/tests/inc/common_wl.test.php b/_test/tests/inc/common_wl.test.php
index 2e34dcae3..4bfde3f39 100644
--- a/_test/tests/inc/common_wl.test.php
+++ b/_test/tests/inc/common_wl.test.php
@@ -142,6 +142,17 @@ class common_wl_test extends DokuWikiTest {
$expect = DOKU_BASE . DOKU_SCRIPT . '/some/one?a=b&c=d';
$this->assertEquals($expect, wl('some:one', 'a=b,c=d', false, '&'));
}
+
+ function test_wl_empty_rev() {
+ global $conf;
+ $conf['useslash'] = 0;
+ $conf['userewrite'] = 0;
+
+ $args = array('a' => 'b', 'c' => 'd', 'rev' => '');
+
+ $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&amp;a=b&amp;c=d';
+ $this->assertEquals($expect, wl('some:', $args));
+ }
diff --git a/_test/tests/inc/init_checkssl.test.php b/_test/tests/inc/init_checkssl.test.php
new file mode 100644
index 000000000..c57d3c37e
--- /dev/null
+++ b/_test/tests/inc/init_checkssl.test.php
@@ -0,0 +1,81 @@
+<?php
+
+class init_checkssl_test extends DokuWikiTest {
+
+ /**
+ * Running behind an SSL proxy, HTTP between server and proxy
+ * HTTPS not set
+ * HTTP_X_FORWARDED_PROTO
+ * set to https
+ */
+ function test1() {
+ $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
+
+ $this->assertEquals(is_ssl(), true);
+ }
+
+ /**
+ * Running behind a plain HTTP proxy, HTTP between server and proxy
+ * HTTPS not set
+ * HTTP_X_FORWARDED_PROTO set to http
+ */
+ function test2() {
+ $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'http';
+
+ $this->assertEquals(is_ssl(), false);
+ }
+
+ /**
+ * Running behind an SSL proxy, HTTP between server and proxy
+ * HTTPS set to off,
+ * HTTP_X_FORWARDED_PROTO set to https
+ */
+ function test3() {
+ $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
+ $_SERVER['HTTPS'] = 'off';
+
+ $this->assertEquals(is_ssl(), true);
+ }
+
+ /**
+ * Not running behind a proxy, HTTPS server
+ * HTTPS set to on,
+ * HTTP_X_FORWARDED_PROTO not set
+ */
+ function test4() {
+ $_SERVER['HTTPS'] = 'on';
+
+ $this->assertEquals(is_ssl(), true);
+ }
+
+ /**
+ * Not running behind a proxy, plain HTTP server
+ * HTTPS not set
+ * HTTP_X_FORWARDED_PROTO not set
+ */
+ function test5() {
+ $this->assertEquals(is_ssl(), false);
+ }
+
+ /**
+ * Not running behind a proxy, plain HTTP server
+ * HTTPS set to off
+ * HTTP_X_FORWARDED_PROTO not set
+ */
+ function test6() {
+ $_SERVER['HTTPS'] = 'off';
+ $this->assertEquals(is_ssl(), false);
+ }
+
+ /**
+ * Running behind an SSL proxy, SSL between proxy and HTTP server
+ * HTTPS set to on,
+ * HTTP_X_FORWARDED_PROTO set to https
+ */
+ function test7() {
+ $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
+ $_SERVER['HTTPS'] = 'on';
+
+ $this->assertEquals(is_ssl(), true);
+ }
+}
diff --git a/_test/tests/inc/input.test.php b/_test/tests/inc/input.test.php
index cec0b80f6..4a8fb8d71 100644
--- a/_test/tests/inc/input.test.php
+++ b/_test/tests/inc/input.test.php
@@ -14,8 +14,58 @@ class input_test extends DokuWikiTest {
'empty' => '',
'emptya' => array(),
'do' => array('save' => 'Speichern'),
+
);
+ /**
+ * custom filter function
+ *
+ * @param $string
+ * @return mixed
+ */
+ public function myfilter($string) {
+ $string = str_replace('foo', 'bar', $string);
+ $string = str_replace('baz', '', $string);
+ return $string;
+ }
+
+ public function test_filter() {
+ $_GET = array(
+ 'foo' => 'foo',
+ 'zstring'=> "foo\0bar",
+ 'znull' => "\0",
+ 'zint' => '42'."\0".'42',
+ 'zintbaz'=> "baz42",
+ );
+ $_POST = $_GET;
+ $_REQUEST = $_GET;
+ $INPUT = new Input();
+
+ $filter = array($this,'myfilter');
+
+ $this->assertNotSame('foobar', $INPUT->str('zstring'));
+ $this->assertSame('foobar', $INPUT->filter()->str('zstring'));
+ $this->assertSame('bar', $INPUT->filter($filter)->str('foo'));
+ $this->assertSame('bar', $INPUT->filter()->str('znull', 'bar', true));
+ $this->assertNotSame('foobar', $INPUT->str('zstring')); // make sure original input is unmodified
+
+ $this->assertNotSame('foobar', $INPUT->get->str('zstring'));
+ $this->assertSame('foobar', $INPUT->get->filter()->str('zstring'));
+ $this->assertSame('bar', $INPUT->get->filter($filter)->str('foo'));
+ $this->assertSame('bar', $INPUT->get->filter()->str('znull', 'bar', true));
+ $this->assertNotSame('foobar', $INPUT->get->str('zstring')); // make sure original input is unmodified
+
+ $this->assertNotSame(4242, $INPUT->int('zint'));
+ $this->assertSame(4242, $INPUT->filter()->int('zint'));
+ $this->assertSame(42, $INPUT->filter($filter)->int('zintbaz'));
+ $this->assertSame(42, $INPUT->filter()->str('znull', 42, true));
+
+ $this->assertSame(true, $INPUT->bool('znull'));
+ $this->assertSame(false, $INPUT->filter()->bool('znull'));
+
+ $this->assertSame('foobar', $INPUT->filter()->valid('zstring', array('foobar', 'bang')));
+ }
+
public function test_str() {
$_REQUEST = $this->data;
$_POST = $this->data;
diff --git a/_test/tests/inc/parser/parser_footnote.test.php b/_test/tests/inc/parser/parser_footnote.test.php
index b47a575de..2457fb031 100644
--- a/_test/tests/inc/parser/parser_footnote.test.php
+++ b/_test/tests/inc/parser/parser_footnote.test.php
@@ -303,7 +303,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('nest', array ( array (
array('footnote_open',array()),
array('listu_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
diff --git a/_test/tests/inc/parser/parser_lists.test.php b/_test/tests/inc/parser/parser_lists.test.php
index e4ef1f83e..6acaff637 100644
--- a/_test/tests/inc/parser/parser_lists.test.php
+++ b/_test/tests/inc/parser/parser_lists.test.php
@@ -13,7 +13,7 @@ class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
$calls = array (
array('document_start',array()),
array('listu_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
@@ -46,7 +46,7 @@ class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
$calls = array (
array('document_start',array()),
array('listo_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
@@ -80,7 +80,7 @@ class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
$calls = array (
array('document_start',array()),
array('listo_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
@@ -109,7 +109,7 @@ class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
$calls = array (
array('document_start',array()),
array('listu_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
@@ -138,7 +138,7 @@ class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
$calls = array (
array('document_start',array()),
array('listo_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
@@ -188,7 +188,7 @@ Bar');
array('cdata',array("Foo")),
array('p_close',array()),
array('listu_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
@@ -227,7 +227,7 @@ Bar');
$calls = array (
array('document_start',array()),
array('listu_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('strong_open',array()),
array('cdata',array("A")),
@@ -262,7 +262,7 @@ Bar');
$calls = array (
array('document_start',array()),
array('listu_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('unformatted',array("A")),
array('listcontent_close',array()),
@@ -291,7 +291,7 @@ Bar');
$calls = array (
array('document_start',array()),
array('listu_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('linebreak',array()),
@@ -355,7 +355,7 @@ Bar');
$calls = array (
array('document_start',array()),
array('listu_open',array()),
- array('listitem_open',array(1)),
+ array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('nest', array( array(
array('footnote_open',array()),
diff --git a/_test/tests/inc/parser/parser_media.test.php b/_test/tests/inc/parser/parser_media.test.php
new file mode 100644
index 000000000..d9a0626f5
--- /dev/null
+++ b/_test/tests/inc/parser/parser_media.test.php
@@ -0,0 +1,103 @@
+<?php
+require_once 'parser.inc.php';
+
+/**
+ * Tests for the implementation of audio and video files
+ *
+ * @author Michael Große <grosse@cosmocode.de>
+*/
+class TestOfDoku_Parser_Media extends TestOfDoku_Parser {
+
+ function testVideoOGVExternal() {
+ $file = 'http://some.where.far/away.ogv';
+ $parser_response = p_get_instructions('{{' . $file . '}}');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('externalmedia',array($file,null,null,null,null,'cache','details')),
+ array('cdata',array(null)),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+ $this->assertEquals(array_map('stripbyteindex',$parser_response),$calls);
+
+ $Renderer = new Doku_Renderer_xhtml();
+ $url = $Renderer->externalmedia($file,null,null,null,null,'cache','details',true);
+ //print_r("url: " . $url);
+ $video = '<video class="media" width="320" height="240" controls="controls">';
+ $this->assertEquals(substr($url,0,66),$video);
+ $source = '<source src="http://some.where.far/away.ogv" type="video/ogg" />';
+ $this->assertEquals(substr($url,67,64),$source);
+ // work around random token
+ $a_first_part = '<a href="/./lib/exe/fetch.php?cache=&amp;tok=';
+ $a_second_part = '&amp;media=http%3A%2F%2Fsome.where.far%2Faway.ogv" class="media mediafile mf_ogv" title="http://some.where.far/away.ogv">';
+ $this->assertEquals(substr($url,132,45),$a_first_part);
+ $this->assertEquals(substr($url,183,121),$a_second_part);
+ $rest = 'away.ogv</a></video>'."\n";
+ $this->assertEquals(substr($url,304),$rest);
+ }
+
+ /**
+ * unknown extension of external media file
+ */
+ function testVideoVIDExternal() {
+ $file = 'http://some.where.far/away.vid';
+ $parser_response = p_get_instructions('{{' . $file . '}}');
+
+ $calls = array(
+ array('document_start', array()),
+ array('p_open', array()),
+ array('externalmedia', array($file, null, null, null, null, 'cache', 'details')),
+ array('cdata', array(null)),
+ array('p_close', array()),
+ array('document_end', array()),
+ );
+ $this->assertEquals(array_map('stripbyteindex', $parser_response), $calls);
+
+ $Renderer = new Doku_Renderer_xhtml();
+ $url = $Renderer->externalmedia($file, null, null, null, null, 'cache', 'details', true);
+ // work around random token
+ $a_first_part = '<a href="/./lib/exe/fetch.php?tok=';
+ $a_second_part = '&amp;media=http%3A%2F%2Fsome.where.far%2Faway.vid" class="media mediafile mf_vid" title="http://some.where.far/away.vid">';
+ $this->assertEquals(substr($url,0,34),$a_first_part);
+ $this->assertEquals(substr($url,40,121),$a_second_part);
+ $rest = 'away.vid</a>';
+ $this->assertEquals(substr($url,161),$rest);
+ }
+
+
+ function testVideoOGVInternal() {
+ $file = 'wiki:kind_zu_katze.ogv';
+ $parser_response = p_get_instructions('{{' . $file . '}}');
+
+ $calls = array (
+ array('document_start',array()),
+ array('p_open',array()),
+ array('internalmedia',array($file,null,null,null,null,'cache','details')),
+ array('cdata',array(null)),
+ array('p_close',array()),
+ array('document_end',array()),
+ );
+ $this->assertEquals(array_map('stripbyteindex',$parser_response),$calls);
+
+ $Renderer = new Doku_Renderer_xhtml();
+ $url = $Renderer->externalmedia($file,null,null,null,null,'cache','details',true);
+
+ $video = '<video class="media" width="320" height="240" controls="controls" poster="/./lib/exe/fetch.php?media=wiki:kind_zu_katze.png">';
+ $this->assertEquals(substr($url,0,125),$video);
+
+ $source_webm = '<source src="/./lib/exe/fetch.php?media=wiki:kind_zu_katze.webm" type="video/webm" />';
+ $this->assertEquals(substr($url,126,85),$source_webm);
+ $source_ogv = '<source src="/./lib/exe/fetch.php?media=wiki:kind_zu_katze.ogv" type="video/ogg" />';
+ $this->assertEquals(substr($url,212,83),$source_ogv);
+
+ $a_webm = '<a href="/./lib/exe/fetch.php?id=&amp;cache=&amp;media=wiki:kind_zu_katze.webm" class="media mediafile mf_webm" title="wiki:kind_zu_katze.webm (99.1 KB)">kind_zu_katze.webm</a>';
+ $a_ogv = '<a href="/./lib/exe/fetch.php?id=&amp;cache=&amp;media=wiki:kind_zu_katze.ogv" class="media mediafile mf_ogv" title="wiki:kind_zu_katze.ogv (44.8 KB)">kind_zu_katze.ogv</a>';
+ $this->assertEquals(substr($url,296,176),$a_webm);
+ $this->assertEquals(substr($url,472,172),$a_ogv);
+
+ $rest = '</video>'."\n";
+ $this->assertEquals(substr($url,644),$rest);
+ }
+}
diff --git a/_test/tests/lib/exe/js_js_compress.test.php b/_test/tests/lib/exe/js_js_compress.test.php
index b1ae2a84f..648ede07e 100644
--- a/_test/tests/lib/exe/js_js_compress.test.php
+++ b/_test/tests/lib/exe/js_js_compress.test.php
@@ -58,6 +58,18 @@ class js_js_compress_test extends DokuWikiTest {
$this->assertEquals(js_compress($text), 'text.replace(/"/,"//")');
}
+ function test_regex_after_and_with_slashes_outside_string(){
+ $text = 'if ( peng == bla && /pattern\//.test(url)) request = new Something();';
+ $this->assertEquals(js_compress($text),
+ 'if(peng==bla&&/pattern\//.test(url))request=new Something();');
+ }
+
+ function test_regex_after_or_with_slashes_outside_string(){
+ $text = 'if ( peng == bla || /pattern\//.test(url)) request = new Something();';
+ $this->assertEquals(js_compress($text),
+ 'if(peng==bla||/pattern\//.test(url))request=new Something();');
+ }
+
function test_dquot1(){
$text = 'var foo="Now what \\" \'do we//get /*here*/ ?";';
$this->assertEquals(js_compress($text), $text);
@@ -145,6 +157,72 @@ EOF;
$this->assertEquals($out, js_compress($text));
}
+ function test_plusplus1(){
+ $text = 'a = 5 + ++b;';
+ $this->assertEquals('a=5+ ++b;',js_compress($text));
+ }
+
+ function test_plusplus2(){
+ $text = 'a = 5+ ++b;';
+ $this->assertEquals('a=5+ ++b;',js_compress($text));
+ }
+
+ function test_plusplus3(){
+ $text = 'a = 5++ + b;';
+ $this->assertEquals('a=5++ +b;',js_compress($text));
+ }
+
+ function test_plusplus4(){
+ $text = 'a = 5++ +b;';
+ $this->assertEquals('a=5++ +b;',js_compress($text));
+ }
+
+ function test_minusminus1(){
+ $text = 'a = 5 - --b;';
+ $this->assertEquals('a=5- --b;',js_compress($text));
+ }
+
+ function test_minusminus2(){
+ $text = 'a = 5- --b;';
+ $this->assertEquals('a=5- --b;',js_compress($text));
+ }
+
+ function test_minusminus3(){
+ $text = 'a = 5-- - b;';
+ $this->assertEquals('a=5-- -b;',js_compress($text));
+ }
+
+ function test_minusminus4(){
+ $text = 'a = 5-- -b;';
+ $this->assertEquals('a=5-- -b;',js_compress($text));
+ }
+
+ function test_minusplus1(){
+ $text = 'a = 5-- +b;';
+ $this->assertEquals('a=5--+b;',js_compress($text));
+ }
+
+ function test_minusplus2(){
+ $text = 'a = 5-- + b;';
+ $this->assertEquals('a=5--+b;',js_compress($text));
+ }
+
+ function test_plusminus1(){
+ $text = 'a = 5++ - b;';
+ $this->assertEquals('a=5++-b;',js_compress($text));
+ }
+
+ function test_plusminus2(){
+ $text = 'a = 5++ -b;';
+ $this->assertEquals('a=5++-b;',js_compress($text));
+ }
+
+ function test_unusual_signs(){
+ $text='var π = Math.PI, τ = 2 * π, halfπ = π / 2, ε = 1e-6, ε2 = ε * ε, radians = π / 180, degrees = 180 / π;';
+ $this->assertEquals(js_compress($text),
+ 'var π=Math.PI,τ=2*π,halfπ=π/2,ε=1e-6,ε2=ε*ε,radians=π/180,degrees=180/π;');
+ }
+
/**
* Test the files provided with the original JsStrip
*/