Giter VIP home page Giter VIP logo

haxe-doctest's People

Contributors

dependabot[bot] avatar sebthom 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

Watchers

 avatar  avatar  avatar  avatar

Forkers

tynrare sondro

haxe-doctest's Issues

munit should not need to be installed.

munit should not need to be installed but it complains if not listed as a -lib, I don't have it installed, I don't want to install it as I am fine using std or if needed fancy would explore tink.

around line 99 of DocTestGenerator needs amends not sure of detail,
but you can use #if munit

    // generate a new testMethod if required
    if (testMethodAssertions.length == MAX_ASSERTIONS_PER_TEST_METHOD ||
     Std.is(doctestAdapter, HaxeUnitDocTestAdapter) 
    #if munit
       || Std.is(doctestAdapter, MUnitDocTestAdapter) 
    #end

then at end of the file something like...

     static function getDocTestAdapter():DocTestAdapter {
        var clazz:ClassType = Context.getLocalClass().get();
        while (true) {
            if (clazz.module == "hx.doctest.DocTestRunner") return new TestrunnerDocTestAdapter();
            if (clazz.module == "haxe.unit.TestCase") return new HaxeUnitDocTestAdapter();
            if (clazz.module == "utest.Test") return new HaxeUtestDocTestAdapter(); // need this new adaptor
            #if tink_testrunner // to prevent "Type not found : tink.testrunner.Case" in TinkTestrunnerDocTestAdapter when tink_testrunner is not present
            if (clazz.module == "tink.testrunner.Suite") return new TinkTestrunnerDocTestAdapter();
            #end
            if (clazz.superClass == null) break;
            clazz = clazz.superClass.t.get();
        }

        // if no known super class was found, we expect it to be a MUnit test case
        #if munit
          return new MUnitDocTestAdapter();
        #else
          throw 'failed to find suitable TestAdapter';
          return null;
        #end
    }

Broken for haxe 4.2 ( I know it's not yet released ).

Noticed both with your libraries test of itself with tink setup and with one of my using utest that haxe-doctest is failing on haxe4.2 ( I downloaded early version of haxe4.2 for the module-statics ). (Normal dox is working as set that up without any issue).
For instance for this lib which only has two tests.
https://github.com/nanjizal/dsHelper
I get the following message after scanning..

/usr/local/lib/haxeLibrary/haxe-doctest/git/src/hx/doctest/DocTestGenerator.hx:386: [INFO] Generated 2 test assertions.
/usr/local/lib/haxeLibrary/haxe-doctest/git/src/hx/doctest/internal/adapters/UTestDocTestAdapter.hx:40: characters 31-40 : Unknown identifier : assertion
/usr/local/lib/haxeLibrary/haxe-doctest/git/src/hx/doctest/internal/adapters/UTestDocTestAdapter.hx:40: characters 31-40 : For optional function argument 'msg'
src/dsHelper/TestdsHelper.hx:15: lines 15-25 : Defined in this class
/usr/local/lib/haxeLibrary/haxe-doctest/git/src/hx/doctest/internal/adapters/UTestDocTestAdapter.hx:32: characters 31-40 : Unknown identifier : assertion
/usr/local/lib/haxeLibrary/haxe-doctest/git/src/hx/doctest/internal/adapters/UTestDocTestAdapter.hx:32: characters 31-40 : For optional function argument 'msg'
src/dsHelper/TestdsHelper.hx:15: lines 15-25 : Defined in this class
/usr/local/lib/haxeLibrary/haxe-doctest/git/src/hx/doctest/internal/adapters/UTestDocTestAdapter.hx:40: characters 31-40 : Unknown identifier : assertion
/usr/local/lib/haxeLibrary/haxe-doctest/git/src/hx/doctest/internal/adapters/UTestDocTestAdapter.hx:40: characters 31-40 : For optional function argument 'msg'
src/dsHelper/TestdsHelper.hx:15: lines 15-25 : Defined in this class
/usr/local/lib/haxeLibrary/haxe-doctest/git/src/hx/doctest/internal/adapters/UTestDocTestAdapter.hx:32: characters 31-40 : Unknown identifier : assertion
/usr/local/lib/haxeLibrary/haxe-doctest/git/src/hx/doctest/internal/adapters/UTestDocTestAdapter.hx:32: characters 31-40 : For optional function argument 'msg'
src/dsHelper/TestdsHelper.hx:15: lines 15-25 : Defined in this class

Include JSDocs comment header style?

Haxe-doctest only seems to work with test statements where the header is star + one space + three greater than-angles. The JSDocs comment header standard seems to be star + two spaces.

Would be a good thing to allow any number of spaces and/or tabs, I guess.

End of File

despite the workaround in fileInput, MyDocTestRunner.hx is "aborted"
/home/yop/Bureau/lastone/plaf/haxe/lib/haxe-doctest/1,0,3/src/hx/doctest/internal/SourceFile.hx:41: [INFO] Scanning [src/ActivitiesBuilderCheck.hx]... /usr/share/haxe/std/neko/_std/sys/io/FileInput.hx:37: characters 4-9 : Eof /usr/share/haxe/std/haxe/io/Input.hx:176: characters 18-28 : Called from /usr/share/haxe/std/neko/Lib.hx:60: characters 17-37 : Called from /usr/share/haxe/std/haxe/io/Input.hx:183: characters 13-50 : Called from /home/yop/Bureau/lastone/plaf/haxe/lib/haxe-doctest/1,0,3/src/hx/doctest/internal/SourceFile.hx:50: characters 23-43 : Called from <builtin>:1: character 0 : Called from /home/yop/Bureau/lastone/plaf/haxe/lib/haxe-doctest/1,0,3/src/hx/doctest/internal/SourceFile.hx:25: lines 25-87 : Called from /home/yop/Bureau/lastone/plaf/haxe/lib/haxe-doctest/1,0,3/src/hx/doctest/DocTestGenerator.hx:68: characters 22-68 : Called from /home/yop/Bureau/lastone/plaf/haxe/lib/haxe-doctest/1,0,3/src/hx/doctest/internal/DocTestUtils.hx:112: characters 20-32 : Called from /home/yop/Bureau/lastone/plaf/haxe/lib/haxe-doctest/1,0,3/src/hx/doctest/DocTestGenerator.hx:67: lines 67-209 : Called from MyDocTestRunner.hx:1: characters 2-7 : Called from Aborted

haxe version : 3.2.0

Testing abstracts?

Thanx, I like this approach very much!

Is it, or would it be, possible to test abstracts this way aswell as classes?

/ Jonas

haxe.unit has moved to haxelib utest

haxe.unit seems to have moved to haxelib utest :(
https://github.com/haxe-utest/utest

I am currently using haxe 4, preview5, I don't create macros often so I was not sure how to adjust the Adaptor for the new structure.

Your readme will likely also need updating

haxelibs required

-lib utest
-lib haxe-doctest
package;
import utest.Runner;
import utest.Test;
@:build(hx.doctest.DocTestGenerator.generateDocTests())
class MyTests extends utest.Test {
    public static function main() {
        var runner = new Runner();
        runner.addCase( new MyTests() );
        runner.run();
    }
    function new() {
        super();
    }
}

async test

hi,
there is a mode for make async test? for example with a promise or future or callback?

does not allow new line, tricky to make test always readable.

Currently hard to make tests readable? Perhaps there is a built in trick I could use?

This seems to work fine, but it's not very readable.

     /**
     * <pre><code>
     * >>> ({ var a=new Matrix1x2({x:3.,y:1.}); var b=new Matrix1x2({x:4.,y:2.}); var c=new Matrix1x2({x:3.5,y:1.5}); var mid=Matrix1x2.mid(a,b); Equal.equals(mid,c); }) == true
     * </code></pre>
     */
    public static inline
    function mid( a: Matrix1x2, b:Matrix1x2 ): Matrix1x2 {
        return new Matrix1x2( { x: ( a.x + b.x )/2, y:( a.y + b.y )/2 } );
    }

But this fails.

     /**
     * <pre><code>
     * >>> ({ 
                      var a = new Matrix1x2({ x: 3., y: 1. });
                      var b = new Matrix1x2({ x: 4., y: 2. });
                      var c = new Matrix1x2({ x: 3.5, y: 1.5 });
                      var mid = Matrix1x2.mid( a, b );
                      Equal.equals( mid, c ); }) == true
     * </code></pre>
     */
    public static inline
    function mid( a: Matrix1x2, b:Matrix1x2 ): Matrix1x2 {
        return new Matrix1x2( { x: ( a.x + b.x )/2, y:( a.y + b.y )/2 } );
    }

Deep value tests.

Wanted to clarify the recommend deep value testing, and perhaps request more integration or maybe you would like me to attempt to add to documents? Perhaps there is an easier approach?

Found two libraries
https://lib.haxe.org/t/deep%20equal/

Equal seems simpler to use outside of haxe-doctest.
haxelib install equals

So at the moment I am doing:

// abstract Vec3( V3 ) from V3 to V3 { where V3 is typedef x,y,z.
    /**
     * <pre><code>
     * >>> Equal.equals( Vec3.zero(), { x: 0., y: 0., z: 0. } ) == true
     * >>> Equal.equals( Vec3.zero(), new Vec3({ x: 0., y: 0., z: 0. }) ) == true
     * </code></pre>
     */
    public static inline
    function zero(){
        return new Vec3({ x: 0.
                        , y: 0.
                        , z: 0. });
    }

Then setup of project.

package rayTriangle;
import utest.Runner;
import utest.Test;
import utest.ui.Report;
import equals.Equal;   // <- notice this line is needed here not in Vec3 class!
@:build(hx.doctest.DocTestGenerator.generateDocTests())
@:build(utest.utils.TestBuilder.build())
class RayTriangleTests extends utest.Test {
    public static function main() {
        var runner = new Runner();
        runner.addCase( new RayTriangleTests() );
        Report.create(runner);
        runner.run();
    }
    function new() {
        super();
    }
}

Gama11 suggested I try using utest.Assert.same but it returns a success or failure so is more complex ?

I wondered how might be best to move forward. I can use 'equals' initially but think it would be ideal that failures provide specific details.

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.