Quellcode durchsuchen

Create test for unicode symbols

This test is created b/c the same test with extensions would fail (see #317)
Peter Hoffmann vor 8 Jahren
Ursprung
Commit
2fbd780771
1 geänderte Dateien mit 39 neuen und 0 gelöschten Zeilen
  1. 39 0
      tests/unicode.php

+ 39 - 0
tests/unicode.php

@@ -0,0 +1,39 @@
+--TEST
+Test V8::executeString() : Check if imported code works with umlauts
+--SKIPIF--
+<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
+--FILE--
+<?php
+
+# maybe more characters (e.g. from http://www.ltg.ed.ac.uk/~richard/unicode-sample.html?)
+$unicode = 'äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█    ㌀ ㌁ ㌂ ㌃';
+
+# insert unicode via snapshot
+$snapshot = V8Js::createSnapshot("var snapshot = {unicode: '" . $unicode . "'}");
+
+# start V8Js
+$jscript = new V8Js('php', array(), array(), true, $snapshot);
+
+# insert unicode via php var
+$jscript->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===