Skip to content

Commit 4e687c3

Browse files
authored
Merge pull request #332 from stesie/unicode-test
Unicode test
2 parents 3afd98b + 289e382 commit 4e687c3

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/unicode.phpt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
--TEST--
2+
Test V8::executeString() : Check if imported code works with umlauts
3+
--SKIPIF--
4+
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
8+
# maybe more characters (e.g. from http://www.ltg.ed.ac.uk/~richard/unicode-sample.html?)
9+
$unicode = 'äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃';
10+
11+
# insert unicode via snapshot
12+
$snapshot = V8Js::createSnapshot("var snapshot = {unicode: '" . $unicode . "'}");
13+
14+
# start V8Js
15+
$jscript = new V8Js('php', array(), array(), true, $snapshot);
16+
17+
# insert unicode via php var
18+
$jscript->unicode = $unicode;
19+
20+
# insert unicode via executeString
21+
$jscript->executeString("var execStr = {unicode: '" . $unicode . "'}");
22+
23+
# insert via module loader
24+
$jscript->setModuleLoader(function ($path) use ($unicode) {
25+
return "module.exports = {unicode: '" . $unicode . "'}";
26+
});
27+
28+
29+
# return to php
30+
$jscript->executeString("values = {}");
31+
$jscript->executeString("values['snapshot'] = snapshot.unicode");
32+
$jscript->executeString("values['php'] = php.unicode");
33+
$jscript->executeString("values['execStr'] = execStr.unicode");
34+
$jscript->executeString("values['module'] = require('module').unicode");
35+
36+
$values = $jscript->executeString("values");
37+
38+
echo "snapshot: $values->snapshot\n";
39+
echo "php : $values->php\n";
40+
echo "execStr : $values->execStr\n";
41+
echo "module : $values->module\n";
42+
43+
?>
44+
===EOF===
45+
--EXPECT--
46+
snapshot: äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃
47+
php : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃
48+
execStr : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃
49+
module : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃
50+
===EOF===

0 commit comments

Comments
 (0)