🔬 Insight into code refactoring
Switch branches/tags
Nothing to show
Latest commit 426512b Apr 26, 2017 @MadcapJake committed on GitHub Merge pull request #5 from samcv/SPDX-license
Use SPDX identifier in license field of META6.json


🔬 Test::Lab

Build Status Issues License Slack

Careful refactoring of critical paths. A port of Github's Scientist to Perl 6.

How do I start a lab?

Use the lab sub to build a default experiment for you:

use Test::Lab;

class MyWidget {
  method is-allowed($user) {
    lab 'widget-permissions', -> $e {
      $e.use: { $!model.check-user($user).is-valid } # old way
      $e.try: { $user.can('read', $!model) } # new way

Use the Test::Lab::Experiment class to instantiate a default experiment:

use Test::Lab::Experiment;

class MyWidget {
  method allows($user) {
    my $experiment = Test::Lab::Experiment.new(:name<widget-permissions>);
    $experiment.use: { $!model.check-user($user).is-valid } # old way
    $experiment.try: { $user.can :$!model :read } # new way


Change the default Experiment class to publish your results:

class MyExperiment is Test::Lab::Experiment {
  method is-enabled { ... }
  method publish($result) { ... }
Test::Lab::<$experiment-class> = MyExperiment;

Now you can use lab as before and it will utilize your own experiment class. This is highly useful as Test::Lab::Default provides no publishing and thus no way to gain access to the results.