[prev in list] [next in list] [prev in thread] [next in thread]
List: pecl-cvs
Subject: [PECL-CVS] com pecl/languages/v8js: Test ArrayAccess prototype method overwriting: =?UTF-8?Q?tests/a
From: Stefan Siegl <stesie () php ! net>
Date: 2014-11-29 20:28:21
Message-ID: php-mail-fba36bb5295eeb3cbc85a6f4b2562ec61566944747 () git ! php ! net
[Download RAW message or body]
Commit: 5a11ef2468d9f8a5d36ad94915ce9a9da5d39a7e
Author: Stefan Siegl <stesie@brokenpipe.de> Sat, 29 Nov 2014 21:28:21 \
+0100
Parents: b25960786d6177c3857021a9665674cb1e51d183
Branches: master
Link: http://git.php.net/?p=pecl/languages/v8js.git;a=commitdiff;h=5a11ef2468d9f8a5d36ad94915ce9a9da5d39a7e
Log:
Test ArrayAccess prototype method overwriting
If the PHP object implementing ArrayAccess has a method,
that has the same name as one of the Array.prototype methods,
the PHP method shall be called, i.e. overwrite the JS method.
Changed paths:
M tests/array_access_003.phpt
Diff:
diff --git a/tests/array_access_003.phpt b/tests/array_access_003.phpt
index c7a5f1b..22c7f09 100644
--- a/tests/array_access_003.phpt
+++ b/tests/array_access_003.phpt
@@ -36,6 +36,11 @@ class MyArray implements ArrayAccess, Countable {
echo "push << $value\n";
$this->data[] = $value;
}
+
+ public function push($value) {
+ echo "php-side-push << $value\n";
+ $this->data[] = $value;
+ }
}
$v8 = new V8Js();
@@ -50,6 +55,16 @@ var_dump($v8->myarr[3]);
/* And JS should see the changes due to live binding. */
$v8->executeString('var_dump(PHP.myarr.join(","));');
+
+/* Call `push' method, this should trigger the PHP method. */
+$v8->executeString('PHP.myarr.push(42);');
+
+var_dump(count($v8->myarr));
+var_dump($v8->myarr[4]);
+
+/* And JS should see the changes due to live binding. */
+$v8->executeString('var_dump(PHP.myarr.join(","));');
+
?>
===EOF===
--EXPECT--
@@ -59,4 +74,10 @@ int(4)
int(23)
count() = 4
string(16) "one,two,three,23"
+php-side-push << 42
+count() = 5
+int(5)
+int(42)
+count() = 5
+string(19) "one,two,three,23,42"
===EOF===
--
PECL CVS Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic