GithubHelp home page GithubHelp logo

coverme's Introduction

CoverMe

This library provides code coverage for Haxe projects.

STATUS: PRE-ALPHA (very much work in progress, trying out stuff, NOT ready for real world)

It is heavily inspired by mcover, however it's written from scratch in modern Haxe for modern Haxe.

Not much more to say right now, since it's in very early stage of development.

Here's something to play with though: https://nadako.github.io/coverme/

Usage

Don't use it, it's not ready. I'll update the README when it's ready for public usage. :)

Implementation

It's implemented as the build macro that instruments Haxe expressions by adding additional logging function call to each "statement" and "branch", e.g. this:

class MyClass {
    static function myFunction(a:Int) {
        if (a == 10) {
            trace("Ten!");
        } else {
            trace("Not ten!");
        }
    }
}

becomes this (JavaScript output):

MyClass.myFunction = function(a) {
    coverme_Logger.logStatement(0);
    if(coverme_Logger.logBranch(1,a == 10)) {
        coverme_Logger.logStatement(2);
        console.log("Ten!");
    } else {
        coverme_Logger.logStatement(3);
        console.log("Not ten!");
    }
};

As you can see, there are logStatement calls added before each statement in a block. The numbers are identifiers of a statement, created at compile-time. And then there's a mapping from these identifiers to objects containing information about statements, such as file and position (also created at compile-time).

When you run the code, injected logStatements will increase execution counters of their corresponding statements. The logBranch is almost the same, but has two counters (for true and false evaluation results).

After running the code in question, we have all counters there and we can analyze the results and report statements and branches that wasn't evaluated once in a nice HTML page:

Obligatory meme

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.