|
1 | 1 | --TEST
|
2 | 2 | Test V8::executeString() : Check if imported code works with some unicode symbols
|
3 | 3 | --SKIPIF--
|
4 |
| -<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> |
5 |
| ---FILE-- |
6 | 4 | <?php
|
7 |
| -# check if snapshots are supported |
| 5 | +# check if v8js was compiled with snapshot support |
8 | 6 | define('V8_WITH_SNAPSHOT', method_exists("V8Js", "createSnapshot"));
|
9 | 7 |
|
10 | 8 | # maybe more characters (e.g. from http://www.ltg.ed.ac.uk/~richard/unicode-sample.html?)
|
11 | 9 | $unicode = 'äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█ ㌀ ㌁ ㌂ ㌃';
|
12 |
| -$moduleFileBase = 'test'; |
13 | 10 |
|
14 | 11 | # insert unicode via snapshot
|
15 | 12 | if (V8_WITH_SNAPSHOT) {
|
16 | 13 | $snapshot = V8Js::createSnapshot("var snapshot = {unicode: '" . $unicode . "'}");
|
17 | 14 | } else {
|
| 15 | + # argument is only checked for type and further ignored |
18 | 16 | $snapshot = '';
|
19 | 17 | }
|
20 | 18 |
|
21 | 19 | # start V8Js
|
22 | 20 | $jscript = new V8Js('php', array(), array(), true, $snapshot);
|
23 |
| -$jscript->setModuleLoader(function ($path) { |
24 |
| - return file_get_contents($path . ".js"); |
25 |
| -}); |
26 | 21 |
|
27 | 22 | # insert unicode via php var
|
28 | 23 | $jscript->unicode = $unicode;
|
29 | 24 |
|
30 | 25 | # insert unicode via executeString
|
31 | 26 | $jscript->executeString("var execStr = {unicode: '" . $unicode . "'}");
|
32 | 27 |
|
33 |
| -# insert unicode via commonJS module |
34 |
| -file_put_contents("./$moduleFileBase.js", "module.exports = {unicode: '$unicode'}"); |
35 |
| -$jscript->executeString("var module = require('./$moduleFileBase')"); |
36 |
| - |
37 | 28 | # return to php
|
38 | 29 | $jscript->executeString("values = {}");
|
39 | 30 | if (V8_WITH_SNAPSHOT) {
|
40 | 31 | $jscript->executeString("values['snapshot'] = snapshot.unicode");
|
41 | 32 | } else {
|
42 |
| - // if snapshots are not compiled shim this test |
| 33 | + # shim this test |
43 | 34 | $jscript->executeString("values['snapshot'] = '" . $unicode . "'");
|
44 | 35 | }
|
45 | 36 | $jscript->executeString("values['php'] = php.unicode");
|
46 | 37 | $jscript->executeString("values['execStr'] = execStr.unicode");
|
47 |
| -$jscript->executeString("values['module'] = module.unicode"); |
48 | 38 | $values = $jscript->executeString("values");
|
49 | 39 |
|
50 | 40 | echo "snapshot: $values->snapshot\n";
|
51 | 41 | echo "php : $values->php\n";
|
52 | 42 | echo "execStr : $values->execStr\n";
|
53 |
| -echo "module : $values->module\n"; |
54 | 43 | ?>
|
| 44 | +===EOF=== |
55 | 45 | --EXPECT--
|
56 | 46 | snapshot: äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█ ㌀ ㌁ ㌂ ㌃
|
57 | 47 | php : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█ ㌀ ㌁ ㌂ ㌃
|
58 | 48 | execStr : äöüßÜÄÖÜ߀áàâÁÀµ²³▁▂▃▄▅▆▇█ ㌀ ㌁ ㌂ ㌃
|
59 |
| ---CLEAN-- |
60 |
| -<?php |
61 |
| -unlink("./$moduleFileBase.js"); |
62 |
| -?> |
| 49 | +===EOF=== |
0 commit comments