From 2fbd7807717b11f281bd50138ca005b7dc660cdf Mon Sep 17 00:00:00 2001 From: Peter Hoffmann Date: Fri, 9 Jun 2017 14:45:45 +0200 Subject: [PATCH 1/9] Create test for unicode symbols This test is created b/c the same test with extensions would fail (see #317) --- tests/unicode.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/unicode.php diff --git a/tests/unicode.php b/tests/unicode.php new file mode 100644 index 0000000..bdd3f57 --- /dev/null +++ b/tests/unicode.php @@ -0,0 +1,39 @@ +--TEST +Test V8::executeString() : Check if imported code works with umlauts +--SKIPIF-- + +--FILE-- +unicode = $unicode; + +# insert unicode via executeString +$jscript->executeString("var execStr = {unicode: '" . $unicode . "'}"); + +# return to php +$jscript->executeString("values = {}"); +$jscript->executeString("values['snapshot'] = snapshot.unicode"); +$jscript->executeString("values['php'] = php.unicode"); +$jscript->executeString("values['execStr'] = execStr.unicode"); +$values = $jscript->executeString("values", V8Js::FLAG_FORCE_ARRAY); + +echo "snapshot: $values->snapshot\n"; +echo "php : $values->php\n"; +echo "execStr : $values->execStr\n"; +?> +===EOF +--EXPECTF-- +snapshot: äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ +php : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ +execStr : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ +===EOF=== From 2c60547ece9ce22e45738cd4d7313985550cf169 Mon Sep 17 00:00:00 2001 From: Peter Hoffmann Date: Mon, 12 Jun 2017 10:11:02 +0200 Subject: [PATCH 2/9] Update unicode.php removed flagg that was misplaced and would've been useless --- tests/unicode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unicode.php b/tests/unicode.php index bdd3f57..f0c1bc7 100644 --- a/tests/unicode.php +++ b/tests/unicode.php @@ -25,7 +25,7 @@ $jscript->executeString("values = {}"); $jscript->executeString("values['snapshot'] = snapshot.unicode"); $jscript->executeString("values['php'] = php.unicode"); $jscript->executeString("values['execStr'] = execStr.unicode"); -$values = $jscript->executeString("values", V8Js::FLAG_FORCE_ARRAY); +$values = $jscript->executeString("values"); echo "snapshot: $values->snapshot\n"; echo "php : $values->php\n"; From 3559f1797eeff3def2091a228f53e91115ead837 Mon Sep 17 00:00:00 2001 From: Peter Hoffmann Date: Mon, 12 Jun 2017 10:37:54 +0200 Subject: [PATCH 3/9] Create unicode.php Create compatibility with versions compiled without snapshot support --- tests/unicode.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/unicode.php b/tests/unicode.php index f0c1bc7..a8825c9 100644 --- a/tests/unicode.php +++ b/tests/unicode.php @@ -1,15 +1,20 @@ --TEST -Test V8::executeString() : Check if imported code works with umlauts +Test V8::executeString() : Check if imported code works with some unicode symbols --SKIPIF-- - ---FILE-- executeString("var execStr = {unicode: '" . $unicode . "'}"); # return to php $jscript->executeString("values = {}"); -$jscript->executeString("values['snapshot'] = snapshot.unicode"); +if (V8_WITH_SNAPSHOT) { + $jscript->executeString("values['snapshot'] = snapshot.unicode"); +} else { + # shim this test + $jscript->executeString("values['snapshot'] = '" . $unicode . "'"); +} $jscript->executeString("values['php'] = php.unicode"); $jscript->executeString("values['execStr'] = execStr.unicode"); $values = $jscript->executeString("values"); @@ -31,8 +41,8 @@ echo "snapshot: $values->snapshot\n"; echo "php : $values->php\n"; echo "execStr : $values->execStr\n"; ?> -===EOF ---EXPECTF-- +===EOF=== +--EXPECT-- snapshot: äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ php : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ execStr : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ From 202f0beefa093139feabab361720338d83572391 Mon Sep 17 00:00:00 2001 From: Peter Hoffmann Date: Mon, 12 Jun 2017 11:20:11 +0200 Subject: [PATCH 4/9] Renamed to unicode.phpt added test for commonJS modules --- tests/{unicode.php => unicode.phpt} | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) rename tests/{unicode.php => unicode.phpt} (72%) diff --git a/tests/unicode.php b/tests/unicode.phpt similarity index 72% rename from tests/unicode.php rename to tests/unicode.phpt index a8825c9..4d0908d 100644 --- a/tests/unicode.php +++ b/tests/unicode.phpt @@ -1,23 +1,28 @@ --TEST Test V8::executeString() : Check if imported code works with some unicode symbols --SKIPIF-- + +--FILE-- setModuleLoader(function ($path) { + return file_get_contents($path . ".js"); +}); # insert unicode via php var $jscript->unicode = $unicode; @@ -25,25 +30,33 @@ $jscript->unicode = $unicode; # insert unicode via executeString $jscript->executeString("var execStr = {unicode: '" . $unicode . "'}"); +# insert unicode via commonJS module +file_put_contents("./$moduleFileBase.js", "module.exports = {unicode: '$unicode'}"); +$jscript->executeString("var module = require('./$moduleFileBase')"); + # return to php $jscript->executeString("values = {}"); if (V8_WITH_SNAPSHOT) { $jscript->executeString("values['snapshot'] = snapshot.unicode"); } else { - # shim this test + // if snapshots are not compiled shim this test $jscript->executeString("values['snapshot'] = '" . $unicode . "'"); } $jscript->executeString("values['php'] = php.unicode"); $jscript->executeString("values['execStr'] = execStr.unicode"); +$jscript->executeString("values['module'] = module.unicode"); $values = $jscript->executeString("values"); echo "snapshot: $values->snapshot\n"; echo "php : $values->php\n"; echo "execStr : $values->execStr\n"; +echo "module : $values->module\n"; ?> -===EOF=== --EXPECT-- snapshot: äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ php : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ execStr : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ -===EOF=== +--CLEAN-- + From 33b3ff5e1fe7550aa4d45282d149abcb22be173d Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Mon, 25 Sep 2017 15:01:21 +0200 Subject: [PATCH 5/9] Revert "Renamed to unicode.phpt" This reverts commit 202f0beefa093139feabab361720338d83572391. --- tests/{unicode.phpt => unicode.php} | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) rename tests/{unicode.phpt => unicode.php} (72%) diff --git a/tests/unicode.phpt b/tests/unicode.php similarity index 72% rename from tests/unicode.phpt rename to tests/unicode.php index 4d0908d..a8825c9 100644 --- a/tests/unicode.phpt +++ b/tests/unicode.php @@ -1,28 +1,23 @@ --TEST Test V8::executeString() : Check if imported code works with some unicode symbols --SKIPIF-- - ---FILE-- setModuleLoader(function ($path) { - return file_get_contents($path . ".js"); -}); # insert unicode via php var $jscript->unicode = $unicode; @@ -30,33 +25,25 @@ $jscript->unicode = $unicode; # insert unicode via executeString $jscript->executeString("var execStr = {unicode: '" . $unicode . "'}"); -# insert unicode via commonJS module -file_put_contents("./$moduleFileBase.js", "module.exports = {unicode: '$unicode'}"); -$jscript->executeString("var module = require('./$moduleFileBase')"); - # return to php $jscript->executeString("values = {}"); if (V8_WITH_SNAPSHOT) { $jscript->executeString("values['snapshot'] = snapshot.unicode"); } else { - // if snapshots are not compiled shim this test + # shim this test $jscript->executeString("values['snapshot'] = '" . $unicode . "'"); } $jscript->executeString("values['php'] = php.unicode"); $jscript->executeString("values['execStr'] = execStr.unicode"); -$jscript->executeString("values['module'] = module.unicode"); $values = $jscript->executeString("values"); echo "snapshot: $values->snapshot\n"; echo "php : $values->php\n"; echo "execStr : $values->execStr\n"; -echo "module : $values->module\n"; ?> +===EOF=== --EXPECT-- snapshot: äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ php : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ execStr : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ ---CLEAN-- - +===EOF=== From ef90ad70651482ffff613d98bbbc655a43a70983 Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Mon, 25 Sep 2017 15:01:37 +0200 Subject: [PATCH 6/9] Revert "Create unicode.php" This reverts commit 3559f1797eeff3def2091a228f53e91115ead837. --- tests/unicode.php | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/tests/unicode.php b/tests/unicode.php index a8825c9..f0c1bc7 100644 --- a/tests/unicode.php +++ b/tests/unicode.php @@ -1,20 +1,15 @@ --TEST -Test V8::executeString() : Check if imported code works with some unicode symbols +Test V8::executeString() : Check if imported code works with umlauts --SKIPIF-- + +--FILE-- executeString("var execStr = {unicode: '" . $unicode . "'}"); # return to php $jscript->executeString("values = {}"); -if (V8_WITH_SNAPSHOT) { - $jscript->executeString("values['snapshot'] = snapshot.unicode"); -} else { - # shim this test - $jscript->executeString("values['snapshot'] = '" . $unicode . "'"); -} +$jscript->executeString("values['snapshot'] = snapshot.unicode"); $jscript->executeString("values['php'] = php.unicode"); $jscript->executeString("values['execStr'] = execStr.unicode"); $values = $jscript->executeString("values"); @@ -41,8 +31,8 @@ echo "snapshot: $values->snapshot\n"; echo "php : $values->php\n"; echo "execStr : $values->execStr\n"; ?> -===EOF=== ---EXPECT-- +===EOF +--EXPECTF-- snapshot: äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ php : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ execStr : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ From ec49c03c0fe1894f4af21df31ad7c7dd3844d94d Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Mon, 25 Sep 2017 15:03:34 +0200 Subject: [PATCH 7/9] fix test-file syntax --- tests/unicode.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unicode.php b/tests/unicode.php index f0c1bc7..a11bbb9 100644 --- a/tests/unicode.php +++ b/tests/unicode.php @@ -1,4 +1,4 @@ ---TEST +--TEST-- Test V8::executeString() : Check if imported code works with umlauts --SKIPIF-- @@ -31,8 +31,8 @@ echo "snapshot: $values->snapshot\n"; echo "php : $values->php\n"; echo "execStr : $values->execStr\n"; ?> -===EOF ---EXPECTF-- +===EOF=== +--EXPECT-- snapshot: äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ php : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ execStr : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ From d6561fe7dcaabcfd83bd6715cd63892d8120286d Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Mon, 25 Sep 2017 15:03:46 +0200 Subject: [PATCH 8/9] fix test filename --- tests/{unicode.php => unicode.phpt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{unicode.php => unicode.phpt} (100%) diff --git a/tests/unicode.php b/tests/unicode.phpt similarity index 100% rename from tests/unicode.php rename to tests/unicode.phpt From 289e382e63c0171f8ae75f6b547e7f21394f0d6c Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Mon, 25 Sep 2017 15:08:23 +0200 Subject: [PATCH 9/9] re-add module focused unicode test --- tests/unicode.phpt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/unicode.phpt b/tests/unicode.phpt index a11bbb9..58fd2f5 100644 --- a/tests/unicode.phpt +++ b/tests/unicode.phpt @@ -20,20 +20,31 @@ $jscript->unicode = $unicode; # insert unicode via executeString $jscript->executeString("var execStr = {unicode: '" . $unicode . "'}"); +# insert via module loader +$jscript->setModuleLoader(function ($path) use ($unicode) { + return "module.exports = {unicode: '" . $unicode . "'}"; +}); + + # return to php $jscript->executeString("values = {}"); $jscript->executeString("values['snapshot'] = snapshot.unicode"); $jscript->executeString("values['php'] = php.unicode"); $jscript->executeString("values['execStr'] = execStr.unicode"); +$jscript->executeString("values['module'] = require('module').unicode"); + $values = $jscript->executeString("values"); echo "snapshot: $values->snapshot\n"; echo "php : $values->php\n"; echo "execStr : $values->execStr\n"; +echo "module : $values->module\n"; + ?> ===EOF=== --EXPECT-- snapshot: äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ php : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ execStr : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ +module : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃ ===EOF===