Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions source/mir/ndslice/slice.d
Original file line number Diff line number Diff line change
Expand Up @@ -4163,14 +4163,33 @@ version(mir_ndslice_test)
unittest
{
import mir.ndslice.slice: LightImmutableOfLightConstOf, Slice, Contiguous;
import std.meta: staticMap;
// Make `x` immutable with label to ensure trigger of staticMap with immutable lightScope overload
alias T = Slice!(int*, 2, Contiguous, int*);
immutable T x = T.init;
// For compilation of immutable lightScope overload with auto return type inference
alias R = typeof(x.lightScope);
// Ensure `R` is a Slice
static assert(is(T : Slice!(Iterator, 2, Contiguous), Iterator));
// Ensure staticMap working properly
static assert(is(R.Labels[0] == staticMap!(LightImmutableOfLightConstOf, int*)[0]));
import std.meta: staticMap;
// Make `x` immutable with label to ensure trigger of staticMap with immutable lightScope overload
alias T = Slice!(int*, 2, Contiguous, int*);
immutable T x = T.init;
// For compilation of immutable lightScope overload with auto return type inference
alias R = typeof(x.lightScope);
// Ensure `R` is a Slice
static assert(is(R : Slice!(Iterator, 2, Contiguous), Iterator));
// Ensure staticMap working properly
static assert(is(R.Labels[0] == staticMap!(LightImmutableOfLightConstOf, int*)[0]));
}

// Additional test for fix on issue #470
@safe pure nothrow @nogc
version(mir_ndslice_test)
unittest
{
import mir.ndslice.slice: LightImmutableOfLightConstOf, Slice, Contiguous;
import std.meta: staticMap;
// Make `x` immutable with label to ensure trigger of staticMap with immutable lightScope overload
alias T = Slice!(int*, 2, Contiguous, int*, long*);
immutable T x = T.init;
// For compilation of immutable lightScope overload with auto return type inference
alias R = typeof(x.lightScope);
// Ensure `R` is a Slice
static assert(is(R : Slice!(Iterator, 2, Contiguous), Iterator));
// Ensure staticMap working properly
static assert(is(R.Labels[0] == staticMap!(LightImmutableOfLightConstOf, int*, long*)[0]));
static assert(is(R.Labels[1] == staticMap!(LightImmutableOfLightConstOf, int*, long*)[1]));
}
Loading