Skip to content

Commit 4df6e80

Browse files
committed
Add testcase on V8Js::createSnapshot
1 parent a1cdd75 commit 4df6e80

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/create_snapshot_basic.phpt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Test V8Js::createSnapshot() : Basic snapshot creation & re-use
3+
--SKIPIF--
4+
<?php
5+
require_once(dirname(__FILE__) . '/skipif.inc');
6+
7+
if (!method_exists('V8Js', 'createSnapshot')) {
8+
die('SKIP V8Js::createSnapshot not supported');
9+
}
10+
?>
11+
--FILE--
12+
<?php
13+
$doublifySource = <<<EOJS
14+
function doublify(x) {
15+
return 2 * x;
16+
}
17+
EOJS;
18+
19+
$snap = V8Js::createSnapshot($doublifySource);
20+
21+
if (strlen($snap) > 0) {
22+
var_dump("snapshot successfully created");
23+
}
24+
25+
$v8 = new V8Js('PHP', array(), array(), true, $snap);
26+
$v8->executeString('var_dump(doublify(23));');
27+
?>
28+
===EOF===
29+
--EXPECT--
30+
string(29) "snapshot successfully created"
31+
int(46)
32+
===EOF===

0 commit comments

Comments
 (0)