Skip to content

Commit 657a0ff

Browse files
committed
make sure Tuple method unittests aren't massively duplicated
1 parent 21d65b6 commit 657a0ff

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

std/typecons.d

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ template Tuple(Specs...)
464464
alias Types = staticMap!(extractType, fieldSpecs);
465465

466466
///
467-
@safe unittest
467+
static if (Specs.length == 0) @safe unittest
468468
{
469469
alias Fields = Tuple!(int, "id", string, float);
470470
static assert(is(Fields.Types == AliasSeq!(int, string, float)));
@@ -476,7 +476,7 @@ template Tuple(Specs...)
476476
alias fieldNames = staticMap!(extractName, fieldSpecs);
477477

478478
///
479-
@safe unittest
479+
static if (Specs.length == 0) @safe unittest
480480
{
481481
alias Fields = Tuple!(int, "id", string, float);
482482
static assert(Fields.fieldNames == AliasSeq!("id", "", ""));
@@ -492,7 +492,7 @@ template Tuple(Specs...)
492492
mixin(injectNamedFields());
493493

494494
///
495-
@safe unittest
495+
static if (Specs.length == 0) @safe unittest
496496
{
497497
auto t1 = tuple(1, " hello ", 2.3);
498498
assert(t1.toString() == `Tuple!(int, string, double)(1, " hello ", 2.3)`);
@@ -550,7 +550,7 @@ template Tuple(Specs...)
550550
}
551551

552552
///
553-
@safe unittest
553+
static if (Specs.length == 0) @safe unittest
554554
{
555555
alias ISD = Tuple!(int, string, double);
556556
auto tup = ISD(1, "test", 3.2);
@@ -574,7 +574,7 @@ template Tuple(Specs...)
574574
}
575575

576576
///
577-
@safe unittest
577+
static if (Specs.length == 0) @safe unittest
578578
{
579579
int[2] ints;
580580
Tuple!(int, int) t = ints;
@@ -597,7 +597,7 @@ template Tuple(Specs...)
597597
}
598598

599599
///
600-
@safe unittest
600+
static if (Specs.length == 0) @safe unittest
601601
{
602602
alias IntVec = Tuple!(int, int, int);
603603
alias DubVec = Tuple!(double, double, double);
@@ -644,7 +644,7 @@ template Tuple(Specs...)
644644
}
645645

646646
///
647-
@safe unittest
647+
static if (Specs.length == 0) @safe unittest
648648
{
649649
Tuple!(int, string) t1 = tuple(1, "test");
650650
Tuple!(double, string) t2 = tuple(1.0, "test");
@@ -700,7 +700,7 @@ template Tuple(Specs...)
700700
The first `v1` for which `v1 > v2` is true determines
701701
the result. This could lead to unexpected behaviour.
702702
*/
703-
@safe unittest
703+
static if (Specs.length == 0) @safe unittest
704704
{
705705
auto tup1 = tuple(1, 1, 1);
706706
auto tup2 = tuple(1, 100, 100);
@@ -789,7 +789,7 @@ template Tuple(Specs...)
789789
}
790790

791791
///
792-
@safe unittest
792+
static if (Specs.length == 0) @safe unittest
793793
{
794794
auto t0 = tuple(4, "hello");
795795

@@ -887,7 +887,7 @@ template Tuple(Specs...)
887887
}
888888

889889
///
890-
@safe unittest
890+
static if (Specs.length == 0) @safe unittest
891891
{
892892
//replacing names by their current name
893893

@@ -907,7 +907,7 @@ template Tuple(Specs...)
907907
}
908908

909909
///
910-
@safe unittest
910+
static if (Specs.length == 0) @safe unittest
911911
{
912912
//replace names by their position
913913

@@ -927,7 +927,7 @@ template Tuple(Specs...)
927927
assert(t2Named.c == 3);
928928
}
929929

930-
@safe unittest
930+
static if (Specs.length == 0) @safe unittest
931931
{
932932
//check that empty translations work fine
933933
enum string[string] a0 = null;
@@ -966,7 +966,7 @@ template Tuple(Specs...)
966966
}
967967

968968
///
969-
@safe unittest
969+
static if (Specs.length == 0) @safe unittest
970970
{
971971
Tuple!(int, string, float, double) a;
972972
a[1] = "abc";
@@ -1222,6 +1222,12 @@ private template ReverseTupleSpecs(T...)
12221222
}
12231223
}
12241224

1225+
// ensure that internal Tuple unittests are compiled
1226+
unittest
1227+
{
1228+
Tuple!() t;
1229+
}
1230+
12251231
@safe unittest
12261232
{
12271233
import std.conv;

0 commit comments

Comments
 (0)