From 2fbd7807717b11f281bd50138ca005b7dc660cdf Mon Sep 17 00:00:00 2001 From: Peter Hoffmann Date: Fri, 9 Jun 2017 14:45:45 +0200 Subject: [PATCH 1/4] 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/4] 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/4] 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/4] 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-- +