execute_flags_property_writing.phpt 736 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. Test V8::executeString() : Forcing to arrays (property writing)
  3. --SKIPIF--
  4. <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
  5. --FILE--
  6. <?php
  7. $js = <<<'EOT'
  8. PHP.test.foo = { "hello": "world" };
  9. EOT;
  10. $v8 = new V8Js();
  11. $v8->test = new stdClass();
  12. try {
  13. $v8->executeString($js, 'no_flags.js');
  14. var_dump($v8->test);
  15. echo "---\n";
  16. $v8->executeString($js, 'force_to_array.js', V8Js::FLAG_FORCE_ARRAY);
  17. var_dump($v8->test);
  18. } catch (V8JsScriptException $e) {
  19. var_dump($e);
  20. }
  21. ?>
  22. ===EOF===
  23. --EXPECTF--
  24. object(stdClass)#%d (1) {
  25. ["foo"]=>
  26. object(V8Object)#%d (1) {
  27. ["hello"]=>
  28. string(5) "world"
  29. }
  30. }
  31. ---
  32. object(stdClass)#%d (1) {
  33. ["foo"]=>
  34. array(1) {
  35. ["hello"]=>
  36. string(5) "world"
  37. }
  38. }
  39. ===EOF===