0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-11-09 23:08:41 +00:00
phpv8/tests/commonjs_source_naming.phpt
Stefan Siegl 39fff2301e Use module id as JsFileName for V8
This way the information to V8JsScriptException instances are way
more clear since they contain the name of the module that caused
the exception.
2015-12-04 21:46:54 +01:00

28 lines
532 B
PHP

--TEST--
Test V8Js::setModuleLoader : Module source naming
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$JS = <<< EOT
require('./foo//bar');
EOT;
$v8 = new V8Js();
$v8->setModuleLoader(function($module) {
// return code with syntax errors to provoke script exception
return "foo(blar);";
});
try {
$v8->executeString($JS, 'commonjs_source_naming.js');
} catch (V8JsScriptException $e) {
var_dump($e->getJsFileName());
}
?>
===EOF===
--EXPECT--
string(7) "foo/bar"
===EOF===