0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-23 08:21:53 +00:00
phpv8/tests/commonjs_cust_normalise_001.phpt

32 lines
604 B
Plaintext
Raw Normal View History

2015-12-06 12:55:13 +00:00
--TEST--
Test V8Js::setModuleNormaliser : Custom normalisation #001
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$JS = <<< EOT
var foo = require("./test");
EOT;
$v8 = new V8Js();
$v8->setModuleNormaliser(function($base, $module) {
var_dump($base, $module);
return [ "", "test" ];
});
$v8->setModuleLoader(function($module) {
print("setModuleLoader called for ".$module."\n");
return 'exports.bar = 23;';
});
$v8->executeString($JS, 'module.js');
?>
===EOF===
--EXPECT--
string(0) ""
string(6) "./test"
setModuleLoader called for test
===EOF===