Browse Source

Merge branch 'testcov-php_v8js_v8_unset_property'

Stefan Siegl 10 năm trước cách đây
mục cha
commit
edc62b5d7d
1 tập tin đã thay đổi với 38 bổ sung0 xóa
  1. 38 0
      tests/v8_unset_property.phpt

+ 38 - 0
tests/v8_unset_property.phpt

@@ -0,0 +1,38 @@
+--TEST--
+Test V8::executeString() : unset property on V8Object
+--SKIPIF--
+<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
+--FILE--
+<?php
+
+$v8 = new V8Js();
+$a = $v8->executeString('var a = { bla: 23 }; a');
+var_dump($a);
+
+// properties on $a should be unset'able
+unset($a->bla);
+var_dump($a);
+
+$v8->executeString('print(a.bla + "\\n");');
+
+unset($v8);
+
+try {
+	// unset not valid, if $v8 object is disposed
+	unset($a->bla);
+}
+catch(V8JsScriptException $e) {
+	var_dump($e->getMessage());
+}
+?>
+===EOF===
+--EXPECTF--
+object(V8Object)#%d (1) {
+  ["bla"]=>
+  int(23)
+}
+object(V8Object)#%d (0) {
+}
+undefined
+string(55) "Can't access V8Object after V8Js instance is destroyed!"
+===EOF===