cartesianProduct should be @safe

This commit is contained in:
Brad Roberts 2014-10-14 21:37:06 -07:00
parent afc5dbe05b
commit 8e9b035324

View file

@ -13932,7 +13932,7 @@ auto cartesianProduct(R1, R2)(R1 range1, R2 range2)
} }
/// ///
unittest @safe unittest
{ {
auto N = sequence!"n"(0); // the range of natural numbers auto N = sequence!"n"(0); // the range of natural numbers
auto N2 = cartesianProduct(N, N); // the range of all pairs of natural numbers auto N2 = cartesianProduct(N, N); // the range of all pairs of natural numbers
@ -13945,7 +13945,7 @@ unittest
} }
/// ///
unittest @safe unittest
{ {
auto B = [ 1, 2, 3 ]; auto B = [ 1, 2, 3 ];
auto C = [ 4, 5, 6 ]; auto C = [ 4, 5, 6 ];
@ -13958,7 +13958,7 @@ unittest
} }
} }
unittest @safe unittest
{ {
// Test cartesian product of two infinite ranges // Test cartesian product of two infinite ranges
auto Even = sequence!"2*n"(0); auto Even = sequence!"2*n"(0);
@ -13977,7 +13977,7 @@ unittest
assert(canFind(EvenOdd, tuple(42, 1))); assert(canFind(EvenOdd, tuple(42, 1)));
} }
unittest @safe unittest
{ {
// Test cartesian product of an infinite input range and a finite forward // Test cartesian product of an infinite input range and a finite forward
// range. // range.
@ -14013,7 +14013,7 @@ unittest
assert(!canFind(MN.take(100), tuple(100, 200))); assert(!canFind(MN.take(100), tuple(100, 200)));
} }
unittest @safe unittest
{ {
// Test cartesian product of two finite ranges. // Test cartesian product of two finite ranges.
auto X = [1, 2, 3]; auto X = [1, 2, 3];
@ -14037,7 +14037,7 @@ unittest
// And therefore, by set comprehension, XY == Expected // And therefore, by set comprehension, XY == Expected
} }
unittest @safe unittest
{ {
auto N = sequence!"n"(0); auto N = sequence!"n"(0);
@ -14199,7 +14199,7 @@ auto cartesianProduct(RR...)(RR ranges)
return Result(ranges); return Result(ranges);
} }
unittest @safe unittest
{ {
// Issue 10693: cartesian product of empty ranges should be empty. // Issue 10693: cartesian product of empty ranges should be empty.
int[] a, b, c, d, e; int[] a, b, c, d, e;
@ -14215,7 +14215,7 @@ unittest
foreach (_; cprod2) {} // should not crash foreach (_; cprod2) {} // should not crash
} }
unittest @safe unittest
{ {
// .init value of cartesianProduct should be empty // .init value of cartesianProduct should be empty
auto cprod = cartesianProduct([0,0], [1,1], [2,2]); auto cprod = cartesianProduct([0,0], [1,1], [2,2]);
@ -14223,7 +14223,7 @@ unittest
assert(cprod.init.empty); assert(cprod.init.empty);
} }
unittest @safe unittest
{ {
// Issue 13393 // Issue 13393
assert(!cartesianProduct([0],[0],[0]).save.empty); assert(!cartesianProduct([0],[0],[0]).save.empty);
@ -14246,7 +14246,7 @@ auto cartesianProduct(R1, R2, RR...)(R1 range1, R2 range2, RR otherRanges)
); );
} }
unittest @safe unittest
{ {
auto N = sequence!"n"(0); auto N = sequence!"n"(0);
auto N3 = cartesianProduct(N, N, N); auto N3 = cartesianProduct(N, N, N);
@ -14276,7 +14276,7 @@ unittest
// Issue 9878 // Issue 9878
/// ///
unittest @safe unittest
{ {
auto A = [ 1, 2, 3 ]; auto A = [ 1, 2, 3 ];
auto B = [ 'a', 'b', 'c' ]; auto B = [ 'a', 'b', 'c' ];