From 91b1a2fbd22b38f6b5316f77fe5c142e14e267f9 Mon Sep 17 00:00:00 2001 From: Simon Best Date: Thu, 9 May 2013 23:14:02 +0100 Subject: [PATCH] Added a test for CommonJS modules. --- tests/commonjs_modules.phpt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/commonjs_modules.phpt diff --git a/tests/commonjs_modules.phpt b/tests/commonjs_modules.phpt new file mode 100644 index 0000000..dabab66 --- /dev/null +++ b/tests/commonjs_modules.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test V8Js::setModuleLoader : CommonJS modules +--SKIPIF-- + +--FILE-- +setModuleLoader(function($module) { + switch ($module) { + case 'path/to/module1': + return 'print(' . json_encode($module . PHP_EOL) . ');require("./module2");'; + + case 'path/to/module2': + return 'print(' . json_encode($module . PHP_EOL) . ');require("../../module3");'; + + default: + return 'print(' . json_encode($module . PHP_EOL) . ');'; + } +}); + +$v8->executeString($JS, 'module.js'); +?> +===EOF=== +--EXPECT-- +path/to/module1 +path/to/module2 +module3 +===EOF===