propcheck 0.6.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 52

Exhaustive and Randomized Testing

A library for exhaustive and randomized testing of Dart properties, based on enumerators. It is inspired by Haskell's smallcheck and quickcheck. If you don't know these libraries, have a look at the small demo below to get an idea of what it can be useful for. I also wrote a post that goes into more details.

Documentation

The only documentation so far is this README and the API reference.

Quick Start

import 'dart:collection';
import 'package:propcheck/propcheck.dart';
import 'package:enumerators/combinators.dart' as c;
import 'package:unittest/unittest.dart';

// defines append and reverse
part 'demolib.dart';

/* --- the properties to test --- */

// this should always hold
bool good(List xs, List ys) =>
    equals(reverse(append(xs, ys)),
           append(reverse(ys), reverse(xs)));

// this should NOT always hold
bool bad(List xs, List ys) =>
    equals(reverse(append(xs, ys)),
           append(reverse(xs), reverse(ys)));

/* --- how we test them --- */

main() {
  // we define an enumeration of lists of integers
  final boolsLists = c.listsOf(c.bools);

  // 'good' and 'bad' take 2 arguments each so we use forall2
  Property goodProperty = forall2(boolsLists, boolsLists, good);
  Property badProperty = forall2(boolsLists, boolsLists, bad);

  // we test the properties against *every* pair of lists of bools whose
  // combined size is <= 10.
  group('smallcheck', () {
    final sc = new SmallCheck(depth: 10);
    test('good', () => sc.check(goodProperty));
    test('bad', () => sc.check(badProperty));
  });

  // we test the properties against random pairs of lists of bools of
  // combined size 0, 1, ..., 300.
  group('quickcheck', () {
    final qc = new QuickCheck(maxSize: 300, seed: 42);
    test('good', () => qc.check(goodProperty));
    test('bad', () => qc.check(badProperty));
  });
}

Output:

unittest-suite-wait-for-done
PASS: smallcheck good
FAIL: smallcheck bad
  Caught falsified after 11 tests
    argument 1: [true]
    argument 2: [false]
  
  [...]
  
PASS: quickcheck good
FAIL: quickcheck bad
  Caught falsified after 5 tests
    argument 1: [false]
    argument 2: [false, false, true]
  
  [...]

2 PASSED, 2 FAILED, 0 ERRORS

Try it!

git clone https://github.com/polux/propcheck
cd propcheck
pub install
dart example/demo.dart

Enjoy the progress indicator, probably the most elaborate part of this library :)

Propcheck Changlelog

0.5.1

  • Move run_all_tests.sh to tests/run.sh to adhere to pub.drone.io's conventions

0.5.0

  • Added CHANGELOG.md
  • Added experimental propcheck_mirrors library

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  propcheck: "^0.6.0"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:propcheck/propcheck.dart';
  
Version Uploaded Documentation Archive
0.6.0 Mar 2, 2018 Go to the documentation of propcheck 0.6.0 Download propcheck 0.6.0 archive
0.5.1 Sep 18, 2014 Go to the documentation of propcheck 0.5.1 Download propcheck 0.5.1 archive
0.5.0 May 31, 2014 Go to the documentation of propcheck 0.5.0 Download propcheck 0.5.0 archive
0.4.0 Nov 8, 2013 Go to the documentation of propcheck 0.4.0 Download propcheck 0.4.0 archive
0.3.5 Oct 4, 2013 Go to the documentation of propcheck 0.3.5 Download propcheck 0.3.5 archive
0.3.4 Oct 3, 2013 Go to the documentation of propcheck 0.3.4 Download propcheck 0.3.4 archive
0.3.3 Oct 3, 2013 Go to the documentation of propcheck 0.3.3 Download propcheck 0.3.3 archive
0.3.2 Oct 1, 2013 Go to the documentation of propcheck 0.3.2 Download propcheck 0.3.2 archive
0.3.1 May 29, 2013 Go to the documentation of propcheck 0.3.1 Download propcheck 0.3.1 archive
0.3.0 Apr 16, 2013 Go to the documentation of propcheck 0.3.0 Download propcheck 0.3.0 archive

All 23 versions...

Analysis

We analyzed this package on Jul 13, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
6 / 100
Health:
Code health derived from static analysis. [more]
98 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
52
Learn more about scoring.

Platforms

Detected platforms: Flutter, other

Primary library: package:propcheck/propcheck.dart with components: io.

Suggestions

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 3 hints.

    Run dartfmt to format lib/propcheck.dart.

    Run dartfmt to format lib/propcheck_mirrors.dart.

    Similar analysis of the following files failed:

    • lib/src/random.dart (hint)
  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use propcheck.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.21.0 <2.0.0
enumerators >=0.6.0 <0.7.0 0.6.0
Transitive dependencies
rational 0.2.0 0.3.0
Dev dependencies
collection >=0.9.3 <0.10.0
unittest >=0.9.0 <0.10.0