Skip to content

Commit 9bcd21d

Browse files
authored
Enhance UTs related to lightScope and labels (libmir#479)
* Enhance UTs related to lightScope and labels * Replace tabs with spaces
1 parent 98267f4 commit 9bcd21d

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

source/mir/ndslice/slice.d

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4163,14 +4163,33 @@ version(mir_ndslice_test)
41634163
unittest
41644164
{
41654165
import mir.ndslice.slice: LightImmutableOfLightConstOf, Slice, Contiguous;
4166-
import std.meta: staticMap;
4167-
// Make `x` immutable with label to ensure trigger of staticMap with immutable lightScope overload
4168-
alias T = Slice!(int*, 2, Contiguous, int*);
4169-
immutable T x = T.init;
4170-
// For compilation of immutable lightScope overload with auto return type inference
4171-
alias R = typeof(x.lightScope);
4172-
// Ensure `R` is a Slice
4173-
static assert(is(T : Slice!(Iterator, 2, Contiguous), Iterator));
4174-
// Ensure staticMap working properly
4175-
static assert(is(R.Labels[0] == staticMap!(LightImmutableOfLightConstOf, int*)[0]));
4166+
import std.meta: staticMap;
4167+
// Make `x` immutable with label to ensure trigger of staticMap with immutable lightScope overload
4168+
alias T = Slice!(int*, 2, Contiguous, int*);
4169+
immutable T x = T.init;
4170+
// For compilation of immutable lightScope overload with auto return type inference
4171+
alias R = typeof(x.lightScope);
4172+
// Ensure `R` is a Slice
4173+
static assert(is(R : Slice!(Iterator, 2, Contiguous), Iterator));
4174+
// Ensure staticMap working properly
4175+
static assert(is(R.Labels[0] == staticMap!(LightImmutableOfLightConstOf, int*)[0]));
4176+
}
4177+
4178+
// Additional test for fix on issue #470
4179+
@safe pure nothrow @nogc
4180+
version(mir_ndslice_test)
4181+
unittest
4182+
{
4183+
import mir.ndslice.slice: LightImmutableOfLightConstOf, Slice, Contiguous;
4184+
import std.meta: staticMap;
4185+
// Make `x` immutable with label to ensure trigger of staticMap with immutable lightScope overload
4186+
alias T = Slice!(int*, 2, Contiguous, int*, long*);
4187+
immutable T x = T.init;
4188+
// For compilation of immutable lightScope overload with auto return type inference
4189+
alias R = typeof(x.lightScope);
4190+
// Ensure `R` is a Slice
4191+
static assert(is(R : Slice!(Iterator, 2, Contiguous), Iterator));
4192+
// Ensure staticMap working properly
4193+
static assert(is(R.Labels[0] == staticMap!(LightImmutableOfLightConstOf, int*, long*)[0]));
4194+
static assert(is(R.Labels[1] == staticMap!(LightImmutableOfLightConstOf, int*, long*)[1]));
41764195
}

0 commit comments

Comments
 (0)