Jelajahi Sumber

Deprecate V8Js::checkString() in favour of compileString() and add tests.

Taneli Leppa 11 tahun lalu
induk
melakukan
7310c93c1e
3 mengubah file dengan 26 tambahan dan 2 penghapusan
  1. 4 1
      tests/checkstring.phpt
  2. 21 0
      tests/checkstring_compile.phpt
  3. 1 1
      v8js.cc

+ 4 - 1
tests/checkstring.phpt

@@ -15,7 +15,10 @@ try {
 }
 ?>
 ===EOF===
---EXPECT--
+--EXPECTF--
+Deprecated: Function V8Js::checkString() is deprecated in %s on line %d
 bool(true)
+
+Deprecated: Function V8Js::checkString() is deprecated in %s on line %d
 string(60) "V8Js::checkString():1: SyntaxError: Unexpected token ILLEGAL"
 ===EOF===

+ 21 - 0
tests/checkstring_compile.phpt

@@ -0,0 +1,21 @@
+--TEST--
+Test V8::executeString() : Script validator test using compileString
+--SKIPIF--
+<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
+--FILE--
+<?php
+
+$v8 = new V8Js();
+var_dump($v8->compileString('print("Hello World!");'));
+
+try {
+	var_dump($v8->compileString('print("Hello World!);'));
+} catch (V8JsScriptException $e) {
+	var_dump($e->getMessage());
+}
+?>
+===EOF===
+--EXPECTF--
+resource(%d) of type (V8Js script)
+string(62) "V8Js::compileString():1: SyntaxError: Unexpected token ILLEGAL"
+===EOF===

+ 1 - 1
v8js.cc

@@ -1732,7 +1732,7 @@ static const zend_function_entry v8js_methods[] = { /* {{{ */
 	PHP_ME(V8Js,	executeString,			arginfo_v8js_executestring,			ZEND_ACC_PUBLIC)
 	PHP_ME(V8Js,	compileString,			arginfo_v8js_compilestring,			ZEND_ACC_PUBLIC)
 	PHP_ME(V8Js,    executeScript,			arginfo_v8js_executescript,			ZEND_ACC_PUBLIC)
-	PHP_ME(V8Js,    checkString,			arginfo_v8js_checkstring,			ZEND_ACC_PUBLIC)
+	PHP_ME(V8Js,    checkString,			arginfo_v8js_checkstring,			ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
 	PHP_ME(V8Js,	getPendingException,	arginfo_v8js_getpendingexception,	ZEND_ACC_PUBLIC)
 	PHP_ME(V8Js,	setModuleLoader,		arginfo_v8js_setmoduleloader,		ZEND_ACC_PUBLIC)
 	PHP_ME(V8Js,	registerExtension,		arginfo_v8js_registerextension,		ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)