Coder Social home page Coder Social logo

php-quickcheck's People

Contributors

chemaclass avatar jtojnar avatar jwdunne avatar krtek4 avatar potherca avatar steos avatar vinai avatar willf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-quickcheck's Issues

PSR-2 Compliance.

I took the liberty of running php-quickcheck through scrutinizer and most of the issues it finds are PSR2 violations.

Would a PR that makes the code PSR-2 compliant be welcomed?

Generate DateTime objects?

I quickly hacked up this to support testing my class that uses DateTime's extensively.
Could it be of interest to others? The function can of course just be copy-pasted straight into the argument generation, but I figured this might help someone else. If only as an issue that be found through searching.

class GeneratorWithDates extends Gen
{
    /**
     * Generate DateTime objects
     *
     * @return Generator
     */
    public static function dates($from = 1000, $to = 3000)
    {
        return self::choose($from, to)->map(
            function ($i) {
                return new DateTime($i);
            }
        );
    }
}

Make release supporting PHP 7.3

PHP 7.3 still is actively supported for the next 10 months (https://www.php.net/supported-versions.php).
It would be helpful to have php-quickcheck available for builds using 7.3.

Personally I'm also using php-quickcheck in projects that don't yet support PHP 7.4 (sadly).
I haven't seen any technical reasons why php-quickcheck should not run on 7.3. Or am I overlooking something?

Missing count argument to \QCheck\Generator::arraysOf

Clojures gen/vector has multiple arrities:

  • [generator]
  • [generator num-elements]
  • [generator min-elements max-elements]

It's quite handy at times to be able to bound the array, or to have a simple tuple with two identical types. It would be convenient to have this option in steos/quickcheck, too.

Question about the use of static methods

Looking through the code, I encountered many static methods. For various reasons (available on request) this is considered a poor practice for anything that is not a factory(ish) function.

What is the rationale behind making so many things static?

Problematic implementation (speed and memory)

Description

PHP runs out of memory after roughly 30 seconds (during shrinking according to the stacktrace).
The PHP memory_limit set to 2GB.

Here is a simple test that reliably reproduces the issue on my machine

<?php declare(strict_types=1);

use PHPUnit\Framework\TestCase;
use QCheck\Generator as Gen;
use QCheck\Quick;

class QcheckTest extends TestCase
{
    public function testStrings(): void
    {
        $prop = Gen::forAll([Gen::strings()], function ($s): bool {
            $this->assertLessThan(100, strlen($s));
            return true;
        });
        $this->assertNotFail(Quick::check(135, $prop, ['echo' => true]));
    }

    private function assertNotFail(array $result): void
    {
        if (isset($result['fail'])) {
            printf("Tests runs: %d, seed: %s, failing value: \n", $result['num_tests'], $result['seed']);
            var_export($result['fail'][0]);
            throw $result['result'] instanceof Exception ?
                $result['result'] :
                new \PHPUnit\Framework\Exception(
                    sprintf('Property check returned result: "%s"', var_export($result['result'], true))
                );
        }
    }
}

I love clojure.test.check and would love to use PBT in PHP, too. The php-quickcheck API is very nice to use from a developer perspective, but I'm afraid the implementation makes it unusable for practical work. I only took a cursory glance, but from that I guess some of the recursion needs to be replaced with mutating iteration.

Currently I'm using https://github.com/giorgiosironi/eris/ to do PBT, but unfortunately the maintainer isn't responsive. Even though there are issues with Eris, too, it at least allows me to use it during work.
I would very much like to be able to use php-quickcheck, since the API matches what I'm use to from clojure.test.check more closely.

Additional Details

OOM is reached after roughly 30 seconds.
I am running php with -dxdebug.max_nesting_level=9999, otherwise the stack is blown quickly.
PHP Versions: 7.3.8, 7.2.21 and 7.1.26.
Machine: 2.2GHz Intel i7 MBP, 32GB RAM.

Is this project still alive?

I found this repository as I was fiddling around with the idea of creating a similar library and I was wondering whether this repository is still considered to be alive and if not, what considerations led to its discontinued development? I read some remarks about interoperability issues with PHPUnit but couldn't quite make out if that was the main problem.

Anyway, I hope to see this kind of testing framework be more prevalent in the php world so any response would be appreciated!

PHP 7.3 or 7.4?

Why would you have the 7.3 as min requirement in the composer.json but 7.4 in the Dev Setup?

  • What about updating the composer.json to require the >=7.4 version?

Otherwise, I would downgrade the dev setup Dockerfile to use the php:7.3.

I say this because I believe it's better to develop something using the same tool-versions as the real/end environment where it's going to be used.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.