@@ -5,11 +5,33 @@ import std.conv : to;
55import core.time : Duration;
66import core.exception : AssertError ;
77
8+ bool anyErrors = false ;
9+ AssertError [] assertError;
10+ SemVerException[] semVerError;
11+
812void main () {
9- auto r = benchmark! (cmpTest, validationTest, buildTest)(1 );
10- writeln(" cmpTest(): " , to! Duration(r[0 ]));
11- writeln(" validationTest(): " , to! Duration(r[1 ]));
12- writeln(" buildTest(): " , to! Duration(r[2 ]));
13+ write(" cmpTest()... " );
14+ auto cmpTestR = benchmark! (cmpTest)(1 );
15+ writefln(" %s in %s" , anyErrors ? " FAIL" : " OK" , to! Duration(cmpTestR[0 ]));
16+ anyErrors = false ;
17+
18+ write(" validationTest()... " );
19+ auto validationTestR = benchmark! (validationTest)(1 );
20+ writefln(" %s in %s" , anyErrors ? " FAIL" : " OK" , to! Duration(validationTestR[0 ]));
21+ anyErrors = false ;
22+
23+ write(" buildTest()... " );
24+ auto buildTestR = benchmark! (buildTest)(1 );
25+ writefln(" %s in %s" , anyErrors ? " FAIL" : " OK" , to! Duration(buildTestR[0 ]));
26+ anyErrors = false ;
27+
28+ if (assertError)
29+ foreach (AssertError a; assertError)
30+ writeln(a.toString);
31+ if (semVerError)
32+ foreach (SemVerException e; semVerError)
33+ writeln(e.toString);
34+
1335}
1436
1537void cmpTest () {
@@ -35,7 +57,11 @@ void cmpTest() {
3557 assert (SemVer(" 1.0.0+build.34" ) > SemVer(" 1.0.0-rc.42" ));
3658 assert (SemVer(" 1.0.0-rc.1+build.34" ) > SemVer(" 1.0.0-rc.1" ));
3759 } catch (AssertError a) {
38- error(a, __FUNCTION__ );
60+ assertError ~= a;
61+ anyErrors = true ;
62+ } catch (SemVerException e) {
63+ semVerError ~= e;
64+ anyErrors = true ;
3965 }
4066}
4167
@@ -46,7 +72,8 @@ void validationTest() {
4672 SemVer(" 1.0.0-eyyyyup" );
4773 SemVer(" 1.0.0-yay+build" );
4874 } catch (SemVerException e) {
49- error(e, __FUNCTION__ );
75+ semVerError ~= e;
76+ anyErrors = true ;
5077 }
5178}
5279
@@ -59,14 +86,11 @@ void buildTest() {
5986 s.nextMinor;
6087 s.nextMinor;
6188 assert (s.toString == " 35.2.0" );
62- } catch (SemVerException e) {
63- error(e, __FUNCTION__ );
6489 } catch (AssertError a) {
65- error(a, __FUNCTION__ );
90+ assertError ~= a;
91+ anyErrors = true ;
92+ } catch (SemVerException e) {
93+ semVerError ~= e;
94+ anyErrors = true ;
6695 }
6796}
68-
69- void error (T)(T a, string f = __FUNCTION__ ) {
70- writefln(" Error in %s" , f);
71- writeln(a.toString);
72- }
0 commit comments