Ikuspro is opensource.

Google translation:

http://translate.google.com/translate?js=y&prev=_t&hl=es&ie=UTF-8&layout=1&eotf=1&u=http://ivanmosquera.net/index.php/2010/07/26/ikuspro-es-libre/&sl=es&tl=en

Doctest in PHP

dna

Dana prefers Haskell

Doctest is a Python module which allows including tests in the comments (those called doctring). There’s a PHP Pear module Doctest version.

DocTest is an easy way to write tests because using tools such as PHPUnit or Simpletest require a Test Driven Development methodology. Besides, doctests aren’t really an alternative to unit tests but something complementary.

Installing via PEAR:

user@computer:$ pear install -f Testing_DocTest

The doctest is included between <code> tags. The expected output is written after “// expects:”.

  1.  
  2. <?php
  3. /**
  4.  * <code>
  5.  * showNumbers(3);
  6.  *
  7.  * // expects:
  8.  * //0
  9.  * //11
  10.  * //222
  11.  * //3333
  12.  * </code>
  13.  *  
  14.  **/
  15. function showNumbers($num) {
  16.    for($i=0;$i<=$num;$i++) {
  17.       for($j=0;$j<=$i;$j++) {
  18.          echo $i;
  19.       }
  20.       echo "\n";
  21.    }
  22. }

Running the tests :

user@computer:$ phpdt numbers.php.

The test output :

user@computer:$ Processing /tmp/numeros.php
[PASS] function mostrarNumeros

Total time : 0.0253 sec.
Passed tests : 1
Skipped tests : 0
Failed tests : 0

The doctest is usually included next to the phpdoc comment, omitted for clearness.

Doctest by default only considers the test as successful if the output looks exactly the same as the written expected output.
However we can use flags to change this behaviour:

  • NORMALIZE_WHITESPACE: white spaces are ignored.
  • CASE_INSENSITIVE:
  • SKIP: the test is ignored
  • ELLIPSIS: you can use a wildcard as [...]. It’s useful for partial unknown outputs.

An example that uses the ELLIPSIS tag and shows that It’s possible having several tests in the same header:

  1.  
  2. <?php
  3. /**
  4.  * <code>
  5.  * // Usamos ELLIPSIS porque hay una parte de la salida que no podemos predecir
  6.  *
  7.  * // flags: ELLIPSIS
  8.  * echo testString();
  9.  * // expects:
  10.  * // Lo siguiente no se puede predecir [...].
  11.  *
  12.  * </code>
  13.  *
  14.  * <code>
  15.  * // Este es el mismo test pero lo hacemos para ver que podemos dividir la salida con \
  16.  *
  17.  * // flags: ELLIPSIS
  18.  * echo testString();
  19.  * // expects:
  20.  * // Lo siguiente \
  21.  * // no se puede \
  22.  * // predecir [...].
  23.  *
  24.  * </code>
  25.  *
  26.  */
  27. function testString()
  28. {
  29.     return sprintf(‘Lo siguiente no se puede predecir %s’, microtime());
  30. }

If the output is too big We can use “expects-file:” instead of “expects :”.

  1.  
  2. <?php
  3. /**
  4.  * <code>
  5.  * mostrarNumeros(3);
  6.  *
  7.  * // expects-file: mostrarNumeros.txt
  8.  *
  9.  * </code>
  10.  *
  11.  **/
  12. function mostrarNumeros($num) {
  13.    for($i=0;$i<=$num;$i++) {
  14.       for($j=0;$j<=$i;$j++) {
  15.          echo $i;
  16.       }
  17.       echo "\n";
  18.    }
  19. }

We put the raw expected output in mostrarNumeros.txt.

You can also include the whole test in an external file:

  1.  
  2.  * <code>
  3.  * // test-file: tests/test1.doctest
  4.  * </code>

Besides, you might need including code to be interpreted before, useful for things like environmental variables or simulating a HTTP request.

  1.  
  2. /**                                                            
  3.  * This is a file level test.
  4.  *
  5.  * <code>
  6.  * // setup:
  7.  * // $_ENV['OSTYPE'] = ‘linux’;
  8.  * echo OS_TYPE;
  9.  * // expects:
  10.  * // linux
  11.  * </code>
  12.  */
  13. define(‘OS_TYPE’, $_ENV[‘OSTYPE’]);

Links:

http://code.google.com/p/testing-doctest/
http://pear.php.net/package/Testing_DocTest
http://en.wikipedia.org/wiki/Doctest
http://svn.php.net/repository/pear/packages/Testing_DocTest/trunk/tests/test1.php

(Español) Las referencias en PHP: qué son y el porqué de no usarlas

Sorry this post is only in Spanish :
http://ivanmosquera.net/index.php/2010/02/13/las-referencia…que-no-usarlas/?lang=es

Flash/Flex development in Linux : Minibuilder

Adobe no longer develops Flash/Flex Builder for Linux. I’ve found a promising opensource alternative : Minibuilder. It’s an IDE built with Adobe Air.

flash platform

flash platform

Let’s see how to install and use this tool:
(more…)

(Español) Probando Haxe

Sorry, this entry is only available in Español.

(Español) Ikuspro en beta

Sorry, this entry is only available in Español.

(Español) Editores UML gratuitos

Sorry, this entry is only available in Español.