0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-11-14 08:18:41 +00:00
phpv8/tests/commonjs_multiassign.phpt
Stefan Siegl eda74908cc Fix module caching, closes #107
Use v8::Persistent handle to keep module instances around.

Objects cannot be shared between isolates anyhow, hence moved
modules_loaded map from global V8JSG structure to php_v8js_ctx.

Besides fixes a use-after-free on normalised_module_id.
2014-09-19 22:36:27 +00:00

27 lines
446 B
PHP

--TEST--
Test V8Js::setModuleLoader : Assign result multiple times
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$JS = <<< EOT
var foo = require("test");
var bar = require("test");
var_dump(foo.bar);
var_dump(bar.bar);
EOT;
$v8 = new V8Js();
$v8->setModuleLoader(function($module) {
return 'exports.bar = 23;';
});
$v8->executeString($JS, 'module.js');
?>
===EOF===
--EXPECT--
int(23)
int(23)
===EOF===