unittests not being run

Bahman Movaqar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 15 04:59:51 PDT 2016


On 07/15/2016 04:16 PM, Jerry wrote:
> Unittests have to be inside a module to be run on DMD atleast.
> So putting module foo at top should fix it.

Strange.  Still not getting picked up.

    $ dmd --version
    DMD64 D Compiler v2.071.0
    Copyright (c) 1999-2015 by Digital Mars written by Walter Bright

[app.d]
    module app;

    import std.stdio;

    private int incBy1(int i) { return i + 1; }

    unittest {
      assert(incBy1(1) == 200);
    }

    void main() {
      writeln(incBy1(1));  // which prints 2
    }
[/app.d]

    $ dub test
    Generating test runner configuration '__test__library__' for
'library' (library).
    Performing "unittest" build using dmd for x86_64.
    dplay ~master: building configuration "__test__library__"...
    Linking...
    Running ./__test__library__
    All unit tests have been run successfully.

-- 
Bahman


More information about the Digitalmars-d-learn mailing list