Commit:    39d3d5ec138119acf614fb285e92c3bcda7a2555
Author:    Nikita Popov <ni...@php.net>         Sun, 27 May 2012 00:50:27 +0200
Parents:   cbfa96cad59d679502eca002a1e920065f11f871
Branches:  master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=39d3d5ec138119acf614fb285e92c3bcda7a2555

Log:
Add first real generator test

The test implements an xrange() function (the generator version of range()).

Changed paths:
  A  Zend/tests/generators/xrange.phpt


Diff:
diff --git a/Zend/tests/generators/xrange.phpt 
b/Zend/tests/generators/xrange.phpt
new file mode 100644
index 0000000..685c6b3
--- /dev/null
+++ b/Zend/tests/generators/xrange.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Simple generator xrange() test
+--FILE--
+<?php
+
+function *xrange($start, $end, $step = 1) {
+       for ($i = $start; $i <= $end; $i += $step) {
+               yield $i;
+       }
+}
+
+foreach (xrange(10, 20, 2) as $i) {
+       var_dump($i);
+}
+
+?>
+--EXPECT--
+int(10)
+int(12)
+int(14)
+int(16)
+int(18)
+int(20)


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to