@@ -66,6 +66,8 @@ import std.traits;
6666import std.meta : allSatisfy;
6767import std.typecons ; // : tuple, Tuple, Flag, Yes;
6868
69+ import std.internal.attributes : betterC;
70+
6971/**
7072Find `value` _among `values`, returning the 1-based index
7173of the first matching value in `values`, or `0` if `value`
@@ -116,7 +118,7 @@ if (isExpressionTuple!values)
116118}
117119
118120// /
119- @safe unittest
121+ @safe @betterC unittest
120122{
121123 assert (3. among(1 , 42 , 24 , 3 , 2 ));
122124
@@ -133,7 +135,7 @@ if (isExpressionTuple!values)
133135Alternatively, `values` can be passed at compile-time, allowing for a more
134136efficient search, but one that only supports matching on equality:
135137*/
136- @safe unittest
138+ @safe @betterC unittest
137139{
138140 assert (3. among! (2 , 3 , 4 ));
139141 assert (" bar" .among! (" foo" , " bar" , " baz" ) == 2 );
541543}
542544
543545// /
544- @safe unittest
546+ @safe @betterC unittest
545547{
546548 assert (clamp(2 , 1 , 3 ) == 2 );
547549 assert (clamp(0 , 1 , 3 ) == 1 );
@@ -1575,7 +1577,7 @@ if (T.length >= 2)
15751577}
15761578
15771579// /
1578- @safe unittest
1580+ @safe @betterC unittest
15791581{
15801582 int a = 5 ;
15811583 short b = 6 ;
@@ -1687,7 +1689,7 @@ if (T.length >= 2)
16871689}
16881690
16891691// /
1690- @safe unittest
1692+ @safe @betterC unittest
16911693{
16921694 int a = 5 ;
16931695 short b = 6 ;
@@ -1698,15 +1700,23 @@ if (T.length >= 2)
16981700 auto e = min(a, b, c);
16991701 static assert (is (typeof (e) == double ));
17001702 assert (e == 2 );
1703+ }
17011704
1702- // With arguments of mixed signedness, the return type is the one that can
1703- // store the lowest values.
1704- a = - 10 ;
1705+ /**
1706+ With arguments of mixed signedness, the return type is the one that can
1707+ store the lowest values.
1708+ */
1709+ @safe @betterC unittest
1710+ {
1711+ int a = - 10 ;
17051712 uint f = 10 ;
17061713 static assert (is (typeof (min(a, f)) == int ));
17071714 assert (min(a, f) == - 10 );
1715+ }
17081716
1709- // User-defined types that support comparison with < are supported.
1717+ // / User-defined types that support comparison with < are supported.
1718+ @safe unittest
1719+ {
17101720 import std.datetime ;
17111721 assert (min(Date (2012 , 12 , 21 ), Date (1982 , 1 , 4 )) == Date (1982 , 1 , 4 ));
17121722 assert (min(Date (1982 , 1 , 4 ), Date (2012 , 12 , 21 )) == Date (1982 , 1 , 4 ));
@@ -1985,7 +1995,7 @@ if (isInputRange!Range1 &&
19851995}
19861996
19871997// Test CTFE
1988- @safe pure unittest
1998+ @safe pure @betterC unittest
19891999{
19902000 enum result1 = isSameLength([1 , 2 , 3 ], [4 , 5 , 6 ]);
19912001 static assert (result1);
@@ -2273,7 +2283,7 @@ if (alternatives.length >= 1 &&
22732283}
22742284
22752285// /
2276- @safe pure unittest
2286+ @safe pure @betterC unittest
22772287{
22782288 const a = 1 ;
22792289 const b = 2 ;
@@ -2292,7 +2302,11 @@ if (alternatives.length >= 1 &&
22922302 auto ef = either(e, f);
22932303 static assert (is (typeof (ef) == int ));
22942304 assert (ef == f);
2305+ }
22952306
2307+ // /
2308+ @safe pure unittest
2309+ {
22962310 immutable p = 1 ;
22972311 immutable q = 2 ;
22982312 auto pq = either(p, q);
@@ -2303,7 +2317,11 @@ if (alternatives.length >= 1 &&
23032317 assert (either(0 , 4 ) == 4 );
23042318 assert (either(0 , 0 ) == 0 );
23052319 assert (either(" " , " a" ) == " " );
2320+ }
23062321
2322+ // /
2323+ @safe pure unittest
2324+ {
23072325 string r = null ;
23082326 assert (either(r, " a" ) == " a" );
23092327 assert (either(" a" , " " ) == " a" );
0 commit comments