diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2022-01-11 12:35:47 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2022-01-11 12:35:47 +0100 |
commit | 19985dbb8c0aa66dc4bf7905abc1148de909097d (patch) | |
tree | 2cd5a5d20d7e80fc2a51adf60d838d8a2c40999e /admin/survey/minify/vendor/mrclay/jsmin-php/tests | |
download | 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.gz 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.bz2 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.lz 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.xz 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.tar.zst 1ka-19985dbb8c0aa66dc4bf7905abc1148de909097d.zip |
Diffstat (limited to 'admin/survey/minify/vendor/mrclay/jsmin-php/tests')
20 files changed, 339 insertions, 0 deletions
diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/before.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/before.js new file mode 100644 index 0000000..e63d477 --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/before.js @@ -0,0 +1,27 @@ +/*! is.js
+
+ (c) 2001 Douglas Crockford
+ 2001 June 3
+*/
+var is={ie:navigator.appName=='Microsoft Internet Explorer',java:navigator.javaEnabled(),ns:navigator.appName=='Netscape',ua:navigator.userAgent.toLowerCase(),version:parseFloat(navigator.appVersion.substr(21))||parseFloat(navigator.appVersion),win:navigator.platform=='Win32'}
+/*!*
+ * preserve this comment, too
+ */
+is.mac=is.ua.indexOf('mac')>=0;if(is.ua.indexOf('opera')>=0){is.ie=is.ns=false;is.opera=true;}
+if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}/*@cc_on
+ /*@if (@_win32)
+ if (is.ie && is.win)
+ document.write("PASS: IE/win honored conditional comment.<br>");
+ @else @*/if(is.ie&&is.win)
+document.write("FAIL: IE/win did not honor multi-line conditional comment.<br>");else
+document.write("PASS: Non-IE/win browser ignores multi-line conditional comment.<br>");/*@end
+@*/var recognizesCondComm=true;//@cc_on/*
+recognizesCondComm=false;//@cc_on*/
+if((is.ie&&is.win)==recognizesCondComm)
+document.write("PASS: IE/win honored single-line conditional comment.<br>");else
+document.write("FAIL: Non-IE/win browser did not ignore single-line conditional comment.<br>");//@cc_on/*
+//@cc_on*/
+//@cc_on/*
+'hello';
+/*!* preserved */
+/*!* preserved */
\ No newline at end of file diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/condcomm.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/condcomm.js new file mode 100644 index 0000000..ff2c122 --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/condcomm.js @@ -0,0 +1,6 @@ +var isWin;/*@cc_on
+ @if (@_win32)
+ isWin = true;
+ @else @*/isWin=false;/*@end
+@*/isWin=/*@cc_on!*/!1;var recognizesCondComm=true;//@cc_on/*
+recognizesCondComm=false;//@cc_on*/
\ No newline at end of file diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/issue144.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/issue144.js new file mode 100644 index 0000000..e339d0a --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/issue144.js @@ -0,0 +1 @@ +a/++b;a*--b;a++-b;a+--b;a-++b;a+-b;a+ ++b;a+--b;a- --b;
\ No newline at end of file diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/issue256.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/issue256.js new file mode 100644 index 0000000..9c3ce2e --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/issue256.js @@ -0,0 +1,2 @@ +!function(){}(window)
+!function(){}(window)
\ No newline at end of file diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/keyword-regex.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/keyword-regex.js new file mode 100644 index 0000000..02ec79e --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/keyword-regex.js @@ -0,0 +1 @@ +return/return/;
\ No newline at end of file diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/not-regexp.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/not-regexp.js new file mode 100644 index 0000000..a7516fb --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/not-regexp.js @@ -0,0 +1 @@ +!function(){return xreturn/foo}();!function(){return xtypeof/foo}();
\ No newline at end of file diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/regexes.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/regexes.js new file mode 100644 index 0000000..d47fdfc --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/regexes.js @@ -0,0 +1,2 @@ +function testIssue74(){return/'/;}
+!function(s){return/^[£$€?.]/.test(s);}();typeof/ ' /;x=/ [/] /;1/foo;(2)/foo;function(){return/foo/};function(){return typeof/foo/};
\ No newline at end of file diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/starts-regex.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/starts-regex.js new file mode 100644 index 0000000..2623624 --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/starts-regex.js @@ -0,0 +1 @@ +/return/.test(bar);
\ No newline at end of file diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/token-regexp.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/token-regexp.js new file mode 100644 index 0000000..13f263c --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/expected/token-regexp.js @@ -0,0 +1 @@ +typeof[/return/];
\ No newline at end of file diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/before.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/before.js new file mode 100644 index 0000000..c28fbe9 --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/before.js @@ -0,0 +1,66 @@ +/*! is.js
+
+ (c) 2001 Douglas Crockford
+ 2001 June 3
+*/
+
+// is
+
+// The -is- object is used to identify the browser. Every browser edition
+// identifies itself, but there is no standard way of doing it, and some of
+// the identification is deceptive. This is because the authors of web
+// browsers are liars. For example, Microsoft's IE browsers claim to be
+// Mozilla 4. Netscape 6 claims to be version 5.
+
+var is = {
+ ie: navigator.appName == 'Microsoft Internet Explorer',
+ java: navigator.javaEnabled(),
+ ns: navigator.appName == 'Netscape',
+ ua: navigator.userAgent.toLowerCase(),
+ version: parseFloat(navigator.appVersion.substr(21)) ||
+ parseFloat(navigator.appVersion),
+ win: navigator.platform == 'Win32'
+}
+/*!*
+ * preserve this comment, too
+ */
+is.mac = is.ua.indexOf('mac') >= 0;
+if (is.ua.indexOf('opera') >= 0) {
+ is.ie = is.ns = false;
+ is.opera = true;
+}
+if (is.ua.indexOf('gecko') >= 0) {
+ is.ie = is.ns = false;
+ is.gecko = true;
+}
+
+/*@cc_on
+ /*@if (@_win32)
+ if (is.ie && is.win)
+ document.write("PASS: IE/win honored conditional comment.<br>");
+ @else @*/
+ if (is.ie && is.win)
+ document.write("FAIL: IE/win did not honor multi-line conditional comment.<br>");
+ else
+ document.write("PASS: Non-IE/win browser ignores multi-line conditional comment.<br>");
+ /*@end
+@*/
+
+var recognizesCondComm = true;
+//@cc_on/*
+recognizesCondComm = false;
+//@cc_on*/
+
+if ((is.ie && is.win) == recognizesCondComm)
+ document.write("PASS: IE/win honored single-line conditional comment.<br>");
+else
+ document.write("FAIL: Non-IE/win browser did not ignore single-line conditional comment.<br>");
+
+// hello
+//@cc_on/*
+// world
+//@cc_on*/
+//@cc_on/*
+'hello';
+/*!* preserved */
+/*!* preserved */
\ No newline at end of file diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/condcomm.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/condcomm.js new file mode 100644 index 0000000..b603aea --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/condcomm.js @@ -0,0 +1,14 @@ +var isWin;
+/*@cc_on
+ @if (@_win32)
+ isWin = true;
+ @else @*/ isWin = false;
+ /*@end
+@*/
+
+isWin = /*@cc_on!*/!1;
+
+var recognizesCondComm = true;
+//@cc_on/*
+recognizesCondComm = false;
+//@cc_on*/
diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/issue144.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/issue144.js new file mode 100644 index 0000000..ba1b297 --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/issue144.js @@ -0,0 +1,9 @@ +a / ++b;
+a * --b;
+a++ - b;
+a + --b;
+a - ++b;
+a + -b;
+a + ++b;
+a + --b;
+a - --b;
\ No newline at end of file diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/issue256.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/issue256.js new file mode 100644 index 0000000..df3dd45 --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/issue256.js @@ -0,0 +1,3 @@ +!function(){}(window)
+
+!function(){}(window)
\ No newline at end of file diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/keyword-regex.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/keyword-regex.js new file mode 100644 index 0000000..5b2a47a --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/keyword-regex.js @@ -0,0 +1,3 @@ +// this is specifically designed so that, if the first "/" is misinterpreted as division,
+// then "/;" will be interpreted as an incomplete regexp, causing a failing test.
+return /return/;
\ No newline at end of file diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/not-regexp.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/not-regexp.js new file mode 100644 index 0000000..26318f6 --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/not-regexp.js @@ -0,0 +1,3 @@ +!function(){return xreturn/foo}();
+
+!function(){return xtypeof/foo}();
diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/regexes.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/regexes.js new file mode 100644 index 0000000..687cbc3 --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/regexes.js @@ -0,0 +1,24 @@ +function testIssue74() {
+ return /'/;
+}
+
+!function(s) {
+ return /^[£$€?.]/.test(s);
+}();
+
+typeof
+ / ' /;
+
+x = / [/] /;
+
+1
+
+/ foo;
+
+(2)
+
+/ foo;
+
+function(){return/foo/};
+
+function(){return typeof/foo/};
diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/starts-regex.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/starts-regex.js new file mode 100644 index 0000000..2e7d08a --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/starts-regex.js @@ -0,0 +1,3 @@ +// this is specifically designed so that, if the first "/" is misinterpreted as division,
+// then "/.test(bar);" will be interpreted as an incomplete regexp, causing a failing test.
+/return/.test(bar);
\ No newline at end of file diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/token-regexp.js b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/token-regexp.js new file mode 100644 index 0000000..fb38f60 --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Resources/minify/input/token-regexp.js @@ -0,0 +1,3 @@ +// this is specifically designed so that, if the first "/" is misinterpreted as division,
+// then "/[;" will be interpreted as an incomplete regexp, causing a failing test.
+typeof [/return/];
\ No newline at end of file diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Tests/JSMin/JSMinTest.php b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Tests/JSMin/JSMinTest.php new file mode 100644 index 0000000..1c9e6dc --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/Tests/JSMin/JSMinTest.php @@ -0,0 +1,168 @@ +<?php
+
+namespace Tests\JSMin;
+
+use JSMin\JSMin;
+
+/**
+ * Copyright (c) 2009, Robert Hafner
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the Stash Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Robert Hafner BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+class JSMinTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @group minify
+ * @dataProvider minifyProvider
+ */
+ public function testMinify($testName, $input, $expected, $actualFile)
+ {
+ $actual = JSMin::minify($input);
+ if ($actual !== $expected && is_writable(dirname($actualFile))) {
+ file_put_contents($actualFile, $actual);
+ }
+ $this->assertEquals($expected, $actual, 'Running Minify Test: ' . $testName);
+ }
+
+ public function testWhitespace() {
+ $this->assertEquals("hello;", JSMin::minify("\r\n\r\nhello;\r\n"));
+ }
+
+ public function testBomRemoval() {
+ $this->assertEquals("hello;", JSMin::minify("\xEF\xBB\xBFhello;"));
+ }
+
+ public function testFuncOverload() {
+ if (!function_exists('mb_strlen') || !((int)ini_get('mbstring.func_overload') & 2)) {
+ $this->markTestIncomplete('Cannot be tested unless mbstring.func_overload is used');
+ return;
+ }
+
+ $input = 'function(s) { return /^[£$€?.]/.test(s); }';
+ $expected = 'function(s){return/^[£$€?.]/.test(s);}';
+ $this->assertEquals($expected, JSMin::minify($input));
+ }
+
+ /**
+ * @dataProvider exceptionProvider
+ */
+ public function testExpections($input, $label, $expClass, $expMessage) {
+ $eClass = $eMsg = '';
+ try {
+ JSMin::minify($input);
+ } catch (\Exception $e) {
+ $eClass = get_class($e);
+ $eMsg = $e->getMessage();
+ }
+ $this->assertTrue(
+ $eClass === $expClass && $eMsg === $expMessage,
+ 'JSMin : throw on ' . $label
+ );
+ }
+
+ public function exceptionProvider() {
+ return array(
+ array(
+ '"Hello'
+ ,'Unterminated String'
+ ,'JSMin\\UnterminatedStringException'
+ ,"JSMin: Unterminated String at byte 5: \"Hello"),
+ array(
+ "return /regexp\n}"
+ ,'Unterminated RegExp'
+ ,'JSMin\\UnterminatedRegExpException'
+ ,"JSMin: Unterminated RegExp at byte 14: /regexp\n"),
+ array(
+ "return/regexp\n}"
+ ,'Unterminated RegExp'
+ ,'JSMin\\UnterminatedRegExpException'
+ ,"JSMin: Unterminated RegExp at byte 13: /regexp\n"),
+ array(
+ ";return/regexp\n}"
+ ,'Unterminated RegExp'
+ ,'JSMin\\UnterminatedRegExpException'
+ ,"JSMin: Unterminated RegExp at byte 14: /regexp\n"),
+ array(
+ ";return /regexp\n}"
+ ,'Unterminated RegExp'
+ ,'JSMin\\UnterminatedRegExpException'
+ ,"JSMin: Unterminated RegExp at byte 15: /regexp\n"),
+ array(
+ "typeof/regexp\n}"
+ ,'Unterminated RegExp'
+ ,'JSMin\\UnterminatedRegExpException'
+ ,"JSMin: Unterminated RegExp at byte 13: /regexp\n"),
+ array(
+ "/* Comment "
+ ,'Unterminated Comment'
+ ,'JSMin\\UnterminatedCommentException'
+ ,"JSMin: Unterminated comment at byte 11: /* Comment "),
+ );
+ }
+
+ /**
+ * This function loads all of the test cases from the specified group.
+ * Groups are created simply by populating the appropriate directories:
+ *
+ * /tests/Resources/GROUPNAME/input/
+ * /tests/Resources/GROUPNAME/output/
+ *
+ * Each test case should have two identically named files, with the raw
+ * javascript going in the test folder and the expected results to be in
+ * the output folder.
+ *
+ * @param $group string
+ * @return array
+ */
+ public function getTestFiles($group)
+ {
+ $baseDir = __DIR__ . '/../../Resources/' . $group . '/';
+ $testDir = $baseDir . 'input/';
+ $expectDir = $baseDir . 'expected/';
+ $actualDir = $baseDir . 'actual/';
+
+ $returnData = array();
+
+ $testFiles = scandir($testDir);
+ foreach ($testFiles as $testFile) {
+ if (substr($testFile, -3) !== '.js' || !file_exists(($expectDir . $testFile))) {
+ continue;
+ }
+
+ $testInput = file_get_contents($testDir . $testFile);
+ $expectedOutput = file_get_contents($expectDir . $testFile);
+ $actualFile = $actualDir . $testFile;
+
+ $returnData[] = array($testFile, $testInput, $expectedOutput, $actualFile);
+ }
+
+ return $returnData;
+ }
+
+ public function minifyProvider()
+ {
+ return $this->getTestFiles('minify');
+ }
+}
diff --git a/admin/survey/minify/vendor/mrclay/jsmin-php/tests/bootstrap.php b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/bootstrap.php new file mode 100644 index 0000000..6fd199e --- /dev/null +++ b/admin/survey/minify/vendor/mrclay/jsmin-php/tests/bootstrap.php @@ -0,0 +1 @@ +<?php
|