From 5875959e25267f034c3c29816da4c751a3927ee8 Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Wed, 23 Feb 2011 08:06:11 +0000 Subject: [PATCH] Very basic JavaScriiptDistiller tests, needs serious expansion --- .../includes/libs/JavaScriptDistillerTest.php | 18 ++++++++++++++++++ tests/phpunit/includes/libs/distiller-in.js | 15 +++++++++++++++ .../includes/libs/distiller-out-full.js | 7 +++++++ tests/phpunit/includes/libs/distiller-out.js | 11 +++++++++++ 4 files changed, 51 insertions(+) create mode 100644 tests/phpunit/includes/libs/JavaScriptDistillerTest.php create mode 100644 tests/phpunit/includes/libs/distiller-in.js create mode 100644 tests/phpunit/includes/libs/distiller-out-full.js create mode 100644 tests/phpunit/includes/libs/distiller-out.js diff --git a/tests/phpunit/includes/libs/JavaScriptDistillerTest.php b/tests/phpunit/includes/libs/JavaScriptDistillerTest.php new file mode 100644 index 0000000000..ddacd1e4df --- /dev/null +++ b/tests/phpunit/includes/libs/JavaScriptDistillerTest.php @@ -0,0 +1,18 @@ +assertEquals( $out, JavaScriptDistiller::stripWhiteSpace( $in ) ); + $this->assertEquals( $outFull, JavaScriptDistiller::stripWhiteSpace( $in, true ) ); + } + + private static function read( $file ) { + $text = file_get_contents( dirname( __FILE__ ) . "/$file" ); + return str_replace( "\r\n", "\n", $text ); + } +} \ No newline at end of file diff --git a/tests/phpunit/includes/libs/distiller-in.js b/tests/phpunit/includes/libs/distiller-in.js new file mode 100644 index 0000000000..66116957e7 --- /dev/null +++ b/tests/phpunit/includes/libs/distiller-in.js @@ -0,0 +1,15 @@ +/* this is a comment */ +/* a multi- + line comment */ +/* a /* weird comment */ +// one-line comment +var string = /* comment */'/* comment in string */'; + +move_to_the_same_line() + + dont_move(); + +if ( / a + bfoo.* /i.test( bar ) && ( a / b ) * c + d - e) { /* blah */ + statement(); + statement() +} \ No newline at end of file diff --git a/tests/phpunit/includes/libs/distiller-out-full.js b/tests/phpunit/includes/libs/distiller-out-full.js new file mode 100644 index 0000000000..ae0b35671d --- /dev/null +++ b/tests/phpunit/includes/libs/distiller-out-full.js @@ -0,0 +1,7 @@ + + + + +var string='/* comment in string */';move_to_the_same_line() +dont_move();if(/ a + bfoo.* /i.test(bar)&&(a/ b ) * c + d - e){ +statement();statement()} \ No newline at end of file diff --git a/tests/phpunit/includes/libs/distiller-out.js b/tests/phpunit/includes/libs/distiller-out.js new file mode 100644 index 0000000000..1886143428 --- /dev/null +++ b/tests/phpunit/includes/libs/distiller-out.js @@ -0,0 +1,11 @@ + + + + +var string='/* comment in string */'; +move_to_the_same_line() +dont_move(); +if(/ a + bfoo.* /i.test(bar)&&(a/ b ) * c + d - e) { /*blah*/ +statement(); +statement() +} \ No newline at end of file -- 2.20.1