question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Statistics shrinked label examples and minimum percentage of labels

See original GitHub issue

Thank you so much for your hard work on fast-check! I’ve only recently started to experiment with property based testing, and fast-check is so well-written and well-documented and an absolute joy to work with!

I saw John Hughes’ talk Building on developers’ intuitions and got very excited about the new shrinked label examples and minimum percentage of labels features in QuickCheck. Do you think it would be possible to add these features to this great library?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:23 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
dubzzzcommented, Apr 8, 2019

Thanks a lot for those great references, I will have a deeper look into the approach in order to see how I can bring it into fast-check.

It is good to know, that fast-check already has limited support for labelled inputs. fc.statistics is able to show the user how many generated values are generated for each label:

const fc = require('fast-check');

const kvPairArb = fc.tuple(fc.integer(-10, 10), fc.integer());
const kvPairEqual = (a, b) => a[0] === b[0];

fc.statistics(
    // Property you would have passed into fc.assert
    fc.property(
        fc.set(kvPairArb, kvPairEqual),
        kvPairArb,
        () => true // code under test
    ),
    // Labeling function
    // can either return a single string label or an array of multiple string labels
    ([vs, [k, v]]) => {
        const label = vs.length === 0 ? 'empty'
            : Math.min(...vs.map(([kv,vv]) => kv)) >= k ? 'at start'
            : Math.max(...vs.map(([kv,vv]) => kv)) <= k ? 'at end'
            : 'at middle';
        return label +', ' + (vs.find(([kv,vv]) => kv === k) ? 'update' : 'create');
    },
    { numRuns: 10000 });

Running code on Runkit: https://runkit.com/dubzzz/5cabc890d332880012e2dcfa

With this code I got:

at middle, create..38.83%
at end, create.....15.73%
at start, create...15.19%
at middle, update..12.99%
empty, create.......9.99%
at start, update....3.98%
at end, update......3.29%

I’ll come back to you asap 😉 Thanks a lot for the references

1reaction
moodmosaiccommented, Jun 17, 2022

So as far as I can tell, I’d have to run the property (via fc.assert) and then re-run the property (via fc.statistics). But this won’t reflect the actual test distribution (the one used initially in fc.assert) right?

Read more comments on GitHub >

github_iconTop Results From Across the Web

The New Nutrition Facts Label Examples of Different ... - FDA
Total Fat 1.5g. Saturated Fat 0g. Trans Fat 0g. Polyunsaturated Fat 0.5g. Monounsaturated Fat 0.5g. Cholesterol 0mg. Sodium 160mg. Fluoride 0mg.
Read more >
How To Read Food and Beverage Labels
Reading food labels can help you make smart food choices. Learn how to read and understand the product date, ingredient list, and Nutrition ......
Read more >
100% Control of Data Labels in Power BI - YouTube
For example, when you only want a label for the highest and lowest point in a chart or when you want to add...
Read more >
Food Product Labeling Basics - La Dept. of Health
Food packaging labels are meant to be more than just ... label that meets regulations is simple and requires only a small ......
Read more >
Nutrition Facts Format Examples
Percent Daily Values are based on a 2,000- calorie diet. Beef, ground, 90% lean / 10% fat, raw. Nutrition Facts. Serving Size 4...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found