zephir-lang / zephir

Zephir is a compiled high-level language aimed to ease the creation of C-extensions for PHP
https://zephir-lang.com
MIT License
3.29k stars 466 forks source link

Introduce zept (Zephir Test) #1098

Open fezfez opened 9 years ago

fezfez commented 9 years ago

Hi,

I propose to introduce zept (Zephir Test) like php do (phpt).

The syntax would be very similar to phpt, an example with a zept for issue#1097

--TEST--
Test that elsif is not evaluated
--FILE--
namespace ZephirBug;

class bug1
{
    public function whatsisMyvar(myvar)
    {
        if is_string(myvar) {
            return "is a var";
        } elseif is_string(myvar[0]) {
            return "is an array and the first element is a string";
        }

        return "unkown";
    }
}
--USAGE--
use ZephirBug\bug1;

$tmp = new bug1();

var_dump($tmp->whatsisMyvar("a string"));
var_dump($tmp->whatsisMyvar(['a string']));
var_dump($tmp->whatsisMyvar(10));
--EXPECT--
string(8) "is a var"
string(45) "is an array and the first element is a string"
string(6) "unkown"

The change between zept and phpt are :

This is just a draft but what do you think ?

Cheers

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/26980981-introduce-zept-zephir-test?utm_campaign=plugin&utm_content=tracker%2F280146&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F280146&utm_medium=issues&utm_source=github).
fezfez commented 9 years ago

@nkt , @phalcon , @steffengy ping !

sergeyklay commented 9 years ago

Looks good to me

sergeyklay commented 9 years ago

+1

steffengy commented 9 years ago

I don't think the advantages to the current solution, are that big that I would invest time into implementing this. I think more important would currently be to convert PHP tests to zephir and add them to zephirs functionality tests (where applicable).

fezfez commented 9 years ago

@steffengy if every one is ok with the concept, i can make a POC :)

steffengy commented 9 years ago

@fezfez you can do that of course, the advantage of this solution would be that you have php (test-code) and zephir code (implementation) in one file and do not have to take a look at multiple files. This would also require converting the existing tests, which is not a trivial amount of work :)

fezfez commented 9 years ago

First POC available https://github.com/fezfez/zephir-testcase.

fezfez commented 9 years ago

See #1104